Skip to content

feat(utils): add Trackio experiment tracking backend#1113

Merged
garrett4wade merged 1 commit into
areal-project:mainfrom
guozhihao-224:feat/trackio-integration
Apr 1, 2026
Merged

feat(utils): add Trackio experiment tracking backend#1113
garrett4wade merged 1 commit into
areal-project:mainfrom
guozhihao-224:feat/trackio-integration

Conversation

@guozhihao-224

@guozhihao-224 guozhihao-224 commented Mar 30, 2026

Copy link
Copy Markdown
Collaborator

Description

Add Trackio (Hugging Face) as a new experiment tracking backend for AReaL, alongside existing WandB, SwanLab, and TensorBoard support. Trackio is a lightweight, local-first tracking library with a wandb-compatible API that supports local dashboards and Hugging Face Spaces deployment.

Related Issue

#1089
#907

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation update
  • ♻️ Refactoring
  • ⚡ Performance improvement
  • ✅ Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • Pre-commit hooks pass (pre-commit run --all-files)
  • Relevant tests pass; new tests added for new functionality
  • Documentation updated (if applicable; built with ./docs/build_all.sh)
  • Branch is up to date with main
  • Self-reviewed via /review-pr command
  • This PR was created by a coding agent via /create-pr
  • This PR is a breaking change

Breaking Change Details (if applicable):

N/A

Additional Context

Key changes:

  • areal/api/cli_args.py: New TrackioConfig dataclass with mode/project/name/space_id fields; added trackio field to StatsLoggerConfig
  • areal/utils/stats_logger.py: Trackio init/log/finish lifecycle integration in StatsLogger
  • areal/utils/logging.py: Add trackio.log() with graceful fallback in helper function
  • pyproject.toml: Add trackio dependency
  • docs/generate_cli_docs.py: Include TrackioConfig in CLI docs generation
  • tests/test_trackio_backend.py: Unit tests for config defaults and StatsLogger integration (mocked)

Trackio defaults to disabled mode, so this change is fully backward-compatible. Enable with stats_logger.trackio.mode=online or stats_logger.trackio.mode=local.

@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 integrates Trackio for experiment tracking, adding a TrackioConfig dataclass and incorporating it into the StatsLogger and logging utilities. The changes include dependency updates, documentation generation, and a comprehensive test suite. A review comment suggests implementing validation for the mode field in TrackioConfig to ensure it only accepts 'disabled', 'online', or 'local'.

Comment thread areal/api/cli_args.py
Comment on lines +1906 to +1925
class TrackioConfig:
"""Configuration for Trackio experiment tracking (Hugging Face).

Trackio is a lightweight, local-first experiment tracking library
with a wandb-compatible API. Dashboards can be viewed locally or
deployed to Hugging Face Spaces.

See: https://github.com/gradio-app/trackio
"""

mode: str = "disabled"
"""Tracking mode. One of "disabled", "online", or "local"."""
project: str | None = None
"""Project name. Defaults to experiment_name if not set."""
name: str | None = None
"""Run name. Defaults to trial_name if not set."""
space_id: str | None = None
"""HF Space ID for remote dashboard deployment (e.g. "user/my-space").
When set, metrics are also pushed to the specified Hugging Face Space."""

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.

medium

To improve robustness and prevent unexpected behavior with invalid modes, it's a good practice to validate the mode field. Many other configuration dataclasses in this file (e.g., NormConfig, RecoverConfig) already use a __post_init__ method for validation. I suggest adding one here to ensure mode is one of the expected values ('disabled', 'online', or 'local').

@dataclass
class TrackioConfig:
    """Configuration for Trackio experiment tracking (Hugging Face).

    Trackio is a lightweight, local-first experiment tracking library
    with a wandb-compatible API. Dashboards can be viewed locally or
    deployed to Hugging Face Spaces.

    See: https://github.com/gradio-app/trackio
    """

    mode: str = "disabled"
    """Tracking mode. One of "disabled", "online", or "local"."""
    project: str | None = None
    """Project name. Defaults to experiment_name if not set."""
    name: str | None = None
    """Run name. Defaults to trial_name if not set."""
    space_id: str | None = None
    """HF Space ID for remote dashboard deployment (e.g. "user/my-space").
    When set, metrics are also pushed to the specified Hugging Face Space."""

    def __post_init__(self):
        """Validate Trackio configuration."""
        valid_modes = {"disabled", "online", "local"}
        if self.mode not in valid_modes:
            raise ValueError(
                f"Invalid trackio mode: '{self.mode}'. Must be one of {valid_modes}."
            )

Integrate Trackio (Hugging Face) as a new experiment tracking option
alongside existing WandB, SwanLab, and TensorBoard backends.

Key changes:
- Add TrackioConfig dataclass with mode/project/name/space_id fields
- Integrate trackio init/log/finish lifecycle in StatsLogger
- Add trackio.log() fallback in logging.py helper function
- Add trackio to pyproject.toml dependencies
- Update CLI docs generator to include TrackioConfig
- Add unit tests for config and StatsLogger integration
@guozhihao-224
guozhihao-224 force-pushed the feat/trackio-integration branch from 939633b to ced8391 Compare March 30, 2026 16:06

@garrett4wade garrett4wade left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@garrett4wade
garrett4wade merged commit c4ccc39 into areal-project:main Apr 1, 2026
6 checks passed
SathyaGnanakumar pushed a commit to danielkiely/AReaL that referenced this pull request Apr 29, 2026
)

Integrate Trackio (Hugging Face) as a new experiment tracking option
alongside existing WandB, SwanLab, and TensorBoard backends.

Key changes:
- Add TrackioConfig dataclass with mode/project/name/space_id fields
- Integrate trackio init/log/finish lifecycle in StatsLogger
- Add trackio.log() fallback in logging.py helper function
- Add trackio to pyproject.toml dependencies
- Update CLI docs generator to include TrackioConfig
- Add unit tests for config and StatsLogger integration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants