Download scripts/validate_task0_baseline.py from myx160/rl-post-train-artifacts: direct link, hf CLI and curl.
- Browser
- Download file 2.37 kB
-
https://huggingface.co/datasets/myx160/rl-post-train-artifacts/resolve/main/scripts/validate_task0_baseline.py
- Command line
-
hf download hf://datasets/myx160/rl-post-train-artifacts/scripts/validate_task0_baseline.py
-
curl -L -o validate_task0_baseline.py https://huggingface.co/datasets/myx160/rl-post-train-artifacts/resolve/main/scripts/validate_task0_baseline.py
2.37 kB
| #!/usr/bin/env python | |
| """Validate Task 0 baseline episode identity and completeness.""" | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| import sys | |
| from pathlib import Path | |
| SCRIPT_DIR = Path(__file__).resolve().parent | |
| if str(SCRIPT_DIR) not in sys.path: | |
| sys.path.insert(0, str(SCRIPT_DIR)) | |
| from task0_baseline_common import ( # noqa: E402 | |
| expected_keys, | |
| load_config, | |
| load_episode_records, | |
| parse_int_spec, | |
| protocol_hash, | |
| require_project_path, | |
| validate_key_set, | |
| ) | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--input-dir", type=Path, required=True) | |
| parser.add_argument( | |
| "--config", | |
| type=Path, | |
| default=Path("configs/baseline/libero10_task0_pi05_sft_formal.yaml"), | |
| ) | |
| parser.add_argument("--expected-seeds", default=None) | |
| parser.add_argument("--expected-trials", default=None) | |
| parser.add_argument("--allow-incomplete", action="store_true") | |
| args = parser.parse_args() | |
| root = require_project_path(args.input_dir, label="result directory") | |
| cfg = load_config(args.config) | |
| cfg_hash = protocol_hash(cfg) | |
| seeds = parse_int_spec(args.expected_seeds, label="seeds") if args.expected_seeds else [int(seed) for seed in cfg.policy_seeds] | |
| trials = parse_int_spec(args.expected_trials, label="trial ids") if args.expected_trials else [int(trial) for trial in cfg.trial_ids] | |
| records = load_episode_records(root, expected_protocol_hash=cfg_hash) | |
| report = validate_key_set(records, expected_keys(seeds, trials)) | |
| report["error_count"] = sum(record["status"] == "error" for record in records) | |
| report["completed_count"] = sum(record["status"] == "completed" for record in records) | |
| report["protocol_sha256"] = cfg_hash | |
| report["video_paths_non_null"] = sum(record["video_path"] is not None for record in records) | |
| print(json.dumps(report, ensure_ascii=False, indent=2, sort_keys=True)) | |
| valid = ( | |
| report["missing"] == [] | |
| and report["unexpected"] == [] | |
| and report["duplicates"] == [] | |
| and report["error_count"] == 0 | |
| and report["video_paths_non_null"] == 0 | |
| and report["observed_count"] == report["expected_count"] | |
| ) | |
| if not args.allow_incomplete and not valid: | |
| return 1 | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |