Skip to content

fix(api): add mode validation for WandBConfig and SwanlabConfig#1134

Merged
garrett4wade merged 1 commit into
areal-project:mainfrom
guozhihao-224:fix/api-validate-tracking-mode
Apr 7, 2026
Merged

fix(api): add mode validation for WandBConfig and SwanlabConfig#1134
garrett4wade merged 1 commit into
areal-project:mainfrom
guozhihao-224:fix/api-validate-tracking-mode

Conversation

@guozhihao-224

@guozhihao-224 guozhihao-224 commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Description

Add __post_init__ validation for tracking mode fields in WandBConfig and SwanlabConfig to catch configuration errors early. Also fix type hint inconsistency in SwanlabConfig.mode (str | Nonestr) to align with validation behavior.

Related Issue

None

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Test coverage improvement

Checklist

  • I have read the Contributing Guide
  • I have run formatting tools (pre-commit or manual)
  • I have run relevant unit tests and they pass
  • I have added tests for new functionality
  • I have updated documentation if needed
  • My branch is up to date with main
  • This PR introduces breaking changes (if yes, fill out details below)
  • If this PR changes documentation, I have built and previewed it locally with jb build docs
  • No critical issues raised by AI reviewers (/gemini review)

Breaking Change Details (if applicable):

Invalid mode values that were previously silently accepted will now raise ValueError at config initialization. This helps users catch configuration errors early rather than failing silently.

Additional Context

Files changed:

  • areal/api/cli_args.py: Add validation and docstrings for mode fields
  • docs/en/cli_reference.md: Update SwanlabConfig.mode type in docs
  • docs/zh/cli_reference.md: Update SwanlabConfig.mode type in docs

@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 validation for the 'mode' attribute in the WandBConfig and SwanlabConfig classes and updates the CLI documentation. The reviewer recommended using dataclasses.field with metadata to improve CLI help consistency and suggested formatting validation error messages as comma-separated lists for better readability.

Comment thread areal/api/cli_args.py Outdated
Comment thread areal/api/cli_args.py
Comment thread areal/api/cli_args.py Outdated
Comment thread areal/api/cli_args.py
Add __post_init__ validation for tracking mode fields to catch
configuration errors early:

- WandBConfig: validate mode is one of {online, offline, disabled, shared}
- SwanlabConfig: validate mode is one of {cloud, local, disabled, offline}
- Use field() with metadata (help + choices) for CLI help consistency
- Fix SwanlabConfig.mode type hint: str | None -> str
- Format error messages as comma-separated lists for readability

BREAKING CHANGE: Invalid mode values that were previously silently
accepted will now raise ValueError at config initialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@guozhihao-224
guozhihao-224 force-pushed the fix/api-validate-tracking-mode branch from 99f9298 to 2df1161 Compare April 2, 2026 14:26

@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 232f673 into areal-project:main Apr 7, 2026
6 checks passed
SathyaGnanakumar pushed a commit to danielkiely/AReaL that referenced this pull request Apr 29, 2026
…l-project#1134)

Add __post_init__ validation for tracking mode fields to catch
configuration errors early:

- WandBConfig: validate mode is one of {online, offline, disabled, shared}
- SwanlabConfig: validate mode is one of {cloud, local, disabled, offline}
- Use field() with metadata (help + choices) for CLI help consistency
- Fix SwanlabConfig.mode type hint: str | None -> str
- Format error messages as comma-separated lists for readability

BREAKING CHANGE: Invalid mode values that were previously silently
accepted will now raise ValueError at config initialization.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
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