Skip to content

fix: validate checkpoint JSON before patching configs - #2

Merged
839390315 merged 2 commits into
RadixRootMind:mainfrom
YeDonS:fix/validate-checkpoint-before-write
Oct 21, 2026
Merged

839390315 merged 2 commits into
RadixRootMind:mainfrom
YeDonS:fix/validate-checkpoint-before-write

Conversation

@YeDonS

@YeDonS YeDonS commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

When policy_preprocessor.json or policy_postprocessor.json is malformed, so101_patch_model_config.py can rewrite earlier checkpoint files and create backups before failing. A failed --mode infer command can therefore leave the policy configuration and processors inconsistent. Valid JSON that is not an object has the same problem.

Parse all three checkpoint JSON objects before invoking any patch helpers. This keeps JSON input failures ahead of config writes and backup creation, while retaining the existing patching and backup behavior.

Six standard-library unittest methods run the actual CLI against temporary copies of the patcher, the two checked-in LLM configs and synthetic checkpoint JSON. They cover:

  • Malformed and non-object JSON in each checkpoint file, in both export and infer modes, preserving the original bytes of all five config files.
  • Missing required files.
  • Successful updates, unrelated metadata, observation renaming, custom paths and action-step settings.
  • Original-content backups, --no-backup and repeated mode switches.

Validation on Python 3.10.20 and 3.12.13: before the fix, eight input-preservation subtests fail; after it, all six test methods pass. Compilation and the PR diff whitespace check also pass.

python3 -m unittest discover -s tests -p test_prepare_model.py -v

This addresses checkpoint JSON parsing and object-type failures. File writes remain sequential; disk errors, concurrent edits, process interruption and invalid LLM Python configs are outside this change. The tests require no vendor SDK, model weights or robot hardware.

@839390315

Copy link
Copy Markdown
Collaborator

Hi @YeDonS, thank you for the contribution.

This PR currently has a merge conflict with the latest main branch in prepare_model.py, so GitHub is blocking the merge.
Once the updated commit is pushed and the tests pass, we will review and merge the PR. Thanks!

@YeDonS YeDonS changed the title fix: validate preprocessor before updating checkpoint config fix: validate checkpoint JSON before patching configs Oct 20, 2026
@839390315
839390315 merged commit 4176f68 into RadixRootMind:main Oct 21, 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.

2 participants