Skip to content

feat: swanlab.html() type#1667

Merged
SAKURA-CAT merged 10 commits into
mainfrom
feat/swanlab-html
Jun 16, 2026
Merged

feat: swanlab.html() type#1667
SAKURA-CAT merged 10 commits into
mainfrom
feat/swanlab-html

Conversation

@Nexisato

@Nexisato Nexisato commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Description

Add swanlab.Html media type for logging HTML content during experiments.

Changes

New media type: Html

  • swanlab/sdk/internal/run/transforms/html/Html TransformMedia implementation
    • Supports raw HTML string, file path (str / pathlib.Path), file object (TextIO), and nesting (Html wrapping Html)
    • Optional caption parameter (consistent with Image, Audio, etc.)
    • Content-addressed storage: {step:03d}-{sha256[:8]}.html
  • swanlab/sdk/typings/run/transforms/html.pyHtmlDataType / HtmlDatasType type aliases

Public API

  • swanlab.Html class exported from swanlab/sdk/__init__.py
  • swanlab/__init__.pyi — full type stub with English docstring

Proto

  • protos/swanlab/metric/column/v1/column.protoCOLUMN_TYPE_HTML enum value
  • Auto-generated Go and Python protobuf artifacts (make proto)

Usage

import swanlab

swanlab.init(project="my-html-project", experiment_name="my-html-run")

# Log raw HTML via swanlab.log
swanlab.log({"report": swanlab.Html("<h1>Hello World</h1>")})

# Log from file with caption
swanlab.log({"page": swanlab.Html("./report.html", caption="My Report")})


swanlab.finish()

@Nexisato Nexisato self-assigned this Jun 4, 2026
@Nexisato Nexisato added 📈 chart SwanLab chart 💪 enhancement New feature or request and removed 📈 chart SwanLab chart labels Jun 4, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces HTML support by adding COLUMN_TYPE_HTML and CHART_TYPE_HTML to the protobuf definitions, and updates the generated Go and Python protobuf files. As there are no review comments, I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Nexisato Nexisato changed the title feat: add html proto feat: swanlab.html() type Jun 4, 2026
@Nexisato Nexisato force-pushed the feat/swanlab-html branch from 3792c15 to 870601b Compare June 8, 2026 02:15
@Nexisato Nexisato requested a review from SAKURA-CAT June 12, 2026 08:05
@Nexisato

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for logging HTML data in SwanLab by introducing Html and log_html to the SDK, updating protobuf definitions with HTML column and chart types, and implementing MIME-type detection during media uploads. The feedback focuses on improving the robustness of the HTML parsing logic, specifically handling potential OSError or ValueError exceptions when checking long raw HTML strings as paths, verifying that input paths are files rather than directories, safely handling non-seekable or binary file-like objects, and ensuring atomic list updates during media upload preparation to prevent list length mismatches.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread swanlab/sdk/internal/run/transforms/html/__init__.py
Comment thread swanlab/sdk/internal/run/transforms/html/__init__.py
Comment thread swanlab/sdk/internal/run/transforms/html/__init__.py Outdated
Comment thread swanlab/sdk/internal/core_python/transport/sender.py
@SAKURA-CAT SAKURA-CAT merged commit a6c414c into main Jun 16, 2026
19 checks passed
@SAKURA-CAT SAKURA-CAT deleted the feat/swanlab-html branch June 16, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

💪 enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants