-
Notifications
You must be signed in to change notification settings - Fork 48
Change how we pass and resolve supervisor policy uris for behavior cloning #4161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
TrainTool.invoke():
1. supervisor_policy_uri on TrainingEnvironmentConfig (in recipes)
2. policy_spec_from_uri() resolves URI → PolicySpec in TrainTool.invoke
3. VectorizedTrainingEnvironment(cfg, supervisor_policy_spec=...)
4. make_vecenv(..., supervisor_policy_spec=...)
5. MettaGridPufferEnv(..., supervisor_policy_spec=...)
packages/mettagrid/python/src/mettagrid/util/uri_resolvers/schemes.py
Outdated
Show resolved
Hide resolved
relh
approved these changes
Dec 4, 2025
nishu-builder
added a commit
that referenced
this pull request
Dec 6, 2025
…oning (#4161) 1. Centralized URI-to-PolicySpec resolution. Now `metta://xxx` works with non-mpt policies A) The MettaSchemeResolver now returns either: - The S3 path containing the policy spec (preferred), or - The raw .mpt checkpoint path for legacy policies B) policy_spec_from_uri() now handles all URI types uniformly: - .mpt files → creates MptPolicy spec - S3 paths → downloads and extracts policy spec archive - Local dirs → loads policy_spec.json directly - resolve_uri() renamed to get_path_to_policy_spec_or_mpt() to clarify its purpose Removed other contextmanager-based load-policy-from-s3 logic, and removed multiple points with custom .mpt handling; now it should all be in policy_spec_from_uri. We now just download to a local cache folder with optional cleanup in atexit handlers 2. Fix passing of behavior-cloning policy URI Before, we passed around an EnvSupervisorConfig containing a URI string that was being misinterpreted as a path. Now, TrainTool resolves the URI into a PolicySpec upfront and passes the resolved spec directly to VectorizedTrainingEnvironment. 3. Cogames CLI policy parsing cleanup The CLI policy parser now uses more shared code for deciding if an input is a URI and parsing it, and allows passing in additional args via key=value pairs. So now you can do e.g.: ``` uv run cogames evaluate -m machina_1.machinatrainerbig -p class=random -p metta://policy/dinky,proportion=2 -p s3://softmax-public/policies/daveey.1x4.cvc.dr.maps.1.bct.0/daveey.1x4.cvc.dr.maps.1.bct.0:v1990.mpt,proportion=4 ``` --------- Co-authored-by: Richard Higgins <richard@relh.net> Co-authored-by: Richard Higgins <richard@softmax.com>
zfogg
pushed a commit
that referenced
this pull request
Dec 20, 2025
…oning (#4161) 1. Centralized URI-to-PolicySpec resolution. Now `metta://xxx` works with non-mpt policies A) The MettaSchemeResolver now returns either: - The S3 path containing the policy spec (preferred), or - The raw .mpt checkpoint path for legacy policies B) policy_spec_from_uri() now handles all URI types uniformly: - .mpt files → creates MptPolicy spec - S3 paths → downloads and extracts policy spec archive - Local dirs → loads policy_spec.json directly - resolve_uri() renamed to get_path_to_policy_spec_or_mpt() to clarify its purpose Removed other contextmanager-based load-policy-from-s3 logic, and removed multiple points with custom .mpt handling; now it should all be in policy_spec_from_uri. We now just download to a local cache folder with optional cleanup in atexit handlers 2. Fix passing of behavior-cloning policy URI Before, we passed around an EnvSupervisorConfig containing a URI string that was being misinterpreted as a path. Now, TrainTool resolves the URI into a PolicySpec upfront and passes the resolved spec directly to VectorizedTrainingEnvironment. 3. Cogames CLI policy parsing cleanup The CLI policy parser now uses more shared code for deciding if an input is a URI and parsing it, and allows passing in additional args via key=value pairs. So now you can do e.g.: ``` uv run cogames evaluate -m machina_1.machinatrainerbig -p class=random -p metta://policy/dinky,proportion=2 -p s3://softmax-public/policies/daveey.1x4.cvc.dr.maps.1.bct.0/daveey.1x4.cvc.dr.maps.1.bct.0:v1990.mpt,proportion=4 ``` --------- Co-authored-by: Richard Higgins <richard@relh.net> Co-authored-by: Richard Higgins <richard@softmax.com>
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.
metta://xxxworks with non-mpt policiesA) The MettaSchemeResolver now returns either:
B) policy_spec_from_uri() now handles all URI types uniformly:
- .mpt files → creates MptPolicy spec
- S3 paths → downloads and extracts policy spec archive
- Local dirs → loads policy_spec.json directly
Removed other contextmanager-based load-policy-from-s3 logic, and removed multiple points with custom .mpt handling; now it should all be in policy_spec_from_uri. We now just download to a local cache folder with optional cleanup in atexit handlers
Before, we passed around an EnvSupervisorConfig containing a URI string that was being misinterpreted as a path. Now, TrainTool resolves the URI into a PolicySpec upfront and passes the resolved spec directly to VectorizedTrainingEnvironment.
The CLI policy parser now uses more shared code for deciding if an input is a URI and parsing it, and allows passing in additional args via key=value pairs.
So now you can do e.g.: