Skip to content

Fix SwanLab callback to forward resume init args#43848

Merged
MekkCyber merged 1 commit intohuggingface:mainfrom
weiguangli-io:codex/transformers-swanlab-resume-id
Feb 10, 2026
Merged

Fix SwanLab callback to forward resume init args#43848
MekkCyber merged 1 commit intohuggingface:mainfrom
weiguangli-io:codex/transformers-swanlab-resume-id

Conversation

@weiguangli-io
Copy link
Copy Markdown
Contributor

Summary

Fixes #43698 by adding SwanLab resume init argument support in the Trainer integration.

What changed

  • SwanLabCallback.setup() now forwards two optional env-based init args to swanlab.init(...):
    • SWANLAB_RUN_ID -> id
    • SWANLAB_RESUME -> resume
  • Added callback docs for both env vars in the SwanLab integration section.
  • Added unit tests to cover:
    • default behavior (no id / resume forwarded)
    • env-driven behavior (id / resume forwarded)

Why env vars?

This keeps the integration change minimal and backward-compatible while providing a direct way to pass SwanLab's resume parameters in resumed training workflows.

Tests

  • PYTHONPATH=src uv run --with pytest pytest -q tests/trainer/test_trainer_callback.py -k SwanLabCallbackTest
  • uvx ruff check tests/trainer/test_trainer_callback.py

Copy link
Copy Markdown
Contributor

@MekkCyber MekkCyber left a comment

Choose a reason for hiding this comment

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

Thank you @OiPunk ! sorry this pr is superseded by #43719, but we can keep the test I guess, wdyt @SunMarc

Copy link
Copy Markdown
Member

@SunMarc SunMarc left a comment

Choose a reason for hiding this comment

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

We can keep the tests yes !

@weiguangli-io
Copy link
Copy Markdown
Contributor Author

Thanks both for the guidance.

I have now trimmed this PR to tests only so it does not modify integration_utils.py anymore (functional change already merged in #43719).

What remains in this PR:

  • tests/trainer/test_trainer_callback.py
  • coverage for SWANLAB_RUN_ID / SWANLAB_RESUME forwarding behavior

I also aligned the test setup with current main behavior (resume_from_checkpoint) to avoid unintended side effects.

Local verification:
PYTHONPATH=src uv run --with pytest pytest -q tests/trainer/test_trainer_callback.py -k SwanLabCallbackTest

If you want, I can further narrow the test scope.

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@MekkCyber MekkCyber merged commit 6df88fa into huggingface:main Feb 10, 2026
16 checks passed
jiosephlee pushed a commit to jiosephlee/transformers_latest that referenced this pull request Feb 11, 2026
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.

SwanLab integration uses outdated swanlab.init() signature

4 participants