Add automatic download and evaluation of pretrained policies - #678
Conversation
|
| _BUNDLE_FILES = ( | ||
| "run-manifest.json", | ||
| "checkpoint.pt", | ||
| "configs/train.yaml", | ||
| "configs/env.yaml", | ||
| "evaluation.json", | ||
| ) |
There was a problem hiding this comment.
Valid manifest files go missing If a bundle uses paths produced by
write_run_manifest(), such as configs/gym.yaml or checkpoints/policy.pt, this fixed list does not download them. RunManifest.load() requires every referenced file to exist, so eval-policy --pretrained fails with FileNotFoundError after downloading the listed files. Download the files named by the manifest instead.
Prompt To Fix With AI
This is a comment left during a code review.
Path: embodichain/data/assets/policy_assets.py
Line: 33-39
Comment:
**Valid manifest files go missing** If a bundle uses paths produced by `write_run_manifest()`, such as `configs/gym.yaml` or `checkpoints/policy.pt`, this fixed list does not download them. `RunManifest.load()` requires every referenced file to exist, so `eval-policy --pretrained` fails with `FileNotFoundError` after downloading the listed files. Download the files named by the manifest instead.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| relative = kwargs["filename"].removeprefix(f"policies/{MODEL}/") | ||
| if not path.exists(): | ||
| path.write_bytes(contents[relative]) | ||
| return str(path) |
There was a problem hiding this comment.
Cache reuse test misses requests The fake downloader leaves existing files untouched, and this test checks only the path and checkpoint modification time. A repeat run could still make network requests without failing the test, leaving the promised cache reuse unverified. Add a check of repeat-run request behavior at the Hub boundary.
Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/data/assets/test_policy_assets.py
Line: 77-80
Comment:
**Cache reuse test misses requests** The fake downloader leaves existing files untouched, and this test checks only the path and checkpoint modification time. A repeat run could still make network requests without failing the test, leaving the promised cache reuse unverified. Add a check of repeat-run request behavior at the Hub boundary.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| or re.fullmatch(r"[0-9a-f]{40}", selected_revision) is None | ||
| ): | ||
| raise ValueError("The model revision did not resolve to a Hub commit") | ||
| index_file = hf_hub_download( |
There was a problem hiding this comment.
[P2] Use the canonical Hugging Face endpoint for policy downloads
When HF_ENDPOINT=https://hf-mirror.com, these calls inherit that mirror. For the pinned index.json, the mirror returns a 308 response without the Hub's commit/ETag metadata (get_hf_file_metadata reports both as None), so hf_hub_download fails before the documented eval-policy --pretrained command can start. The same URL on https://huggingface.co returns the pinned commit and ETag. solver_assets.py already pins the canonical endpoint for this reason. Please use that endpoint consistently for HfApi and both hf_hub_download calls, or otherwise handle incompatible mirrors.
There was a problem hiding this comment.
Fixed in 2c0fd74. HfApi and both hf_hub_download call sites now explicitly use https://huggingface.co, matching solver_assets.py. Standard HTTP proxy settings still apply.
Added regression coverage for pinned and named revisions with HF_ENDPOINT=https://hf-mirror.com. Both cases failed before the fix and pass now. I also verified real downloads into separate empty caches for the default revision and --revision main under that setting; all five bundle files matched the published model. All 47 targeted tests pass.
Description
Add
eval-policy --pretrained <model-id>to download a policy's weights and matching configurations, resolve required robot assets, and run the existing native evaluator from one command.--revisionto select another version.fast-rt.--cache-dirand--outputcontrol their locations.The CLI guide, public API documentation, tests and download dependency declaration are updated accordingly.
Validation:
Type of change
Screenshots
Not applicable: this extends the existing evaluation command.
Checklist
black .command to format the code base.python docs/scripts/check_api_docs.py), if applicable