fix(train): restrict legacy RA-BC migration to JSON checkpoints only#3490
Open
masato-ka wants to merge 3 commits intohuggingface:mainfrom
Open
fix(train): restrict legacy RA-BC migration to JSON checkpoints only#3490masato-ka wants to merge 3 commits intohuggingface:mainfrom
masato-ka wants to merge 3 commits intohuggingface:mainfrom
Conversation
_migrate_legacy_rabc_fields was called for all config files, causing
json.load to raise DecodeError when a YAML config was passed to
lerobot-train for a new training run. Guard the block with an
.endswith(".json") check so migration only runs when resuming from
a JSON checkpoint.
Also adds types-PyYAML to pre-commit mypy additional_dependencies
to fix a pre-existing [import-untyped] error in envs/robotwin.py.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_migrate_legacy_rabc_fields was called for all config files, causing json.load to raise DecodeError when a YAML config was passed to lerobot-train for a new training run. Guard the block with an .endswith(".json") check so migration only runs when resuming from a JSON checkpoint.
Also adds types-PyYAML to pre-commit mypy additional_dependencies to fix a pre-existing [import-untyped] error in envs/robotwin.py.
Title
Short, imperative summary (e.g., "fix(robots): handle None in sensor parser"). See CONTRIBUTING.md for PR conventions.
Summary / Motivation
PR #3480 (cd6b43e) introduced _migrate_legacy_rabc_fields, which was called unconditionally
whenever config_file is not None. Since this function calls json.load() as its first step, passing
a YAML config file via --config_path to start a new training run raised a JSONDecodeError and
aborted the process. This fix adds an .endswith(".json") guard to the migration block so that the
legacy RA-BC migration only runs when resuming from a JSON checkpoint. A clarifying comment was
also added to make the intent clear to future readers. Additionally, a pre-existing mypy
[import-untyped] error in lerobot/envs/robotwin.py (missing types-PyYAML stubs) was resolved by
adding types-PyYAML to the pre-commit mypy additional_dependencies.
Reproduction steps (before fix)
Raises JSONDecodeError on main with #3480 applied
Related issues
What changed
TrainPipelineConfig.from_pretrained from if config_file is not None: to if config_file is not None
and os.path.basename(config_file).endswith(".json"):, preventing json.load from being called on
YAML configs.
the pre-existing [import-untyped] error in lerobot/envs/robotwin.py.
How was this tested (or how to run locally)
Confirmed that resuming from a JSON checkpoint correctly migrates sample_weighting and
sub-options, and that training resumes without error.
Confirmed that running the command below with the fix applied starts training successfully without
a JSONDecodeError.
Checklist (required before merge)
pre-commit run -a)pytest)Reviewer notes