From 3c6c9c690a62e1a28006af7119396374f5e91886 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 31 Oct 2026 10:10:59 +0000 Subject: [PATCH] research: karman reproduce takes explicit model/norm paths; no bytecode written into DynamisLab Co-Authored-By: Claude Opus 5.5 --- research/karman_reproduce/run.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/research/karman_reproduce/run.py b/research/karman_reproduce/run.py index a667557..4c589d3 100644 --- a/research/karman_reproduce/run.py +++ b/research/karman_reproduce/run.py @@ -18,8 +18,9 @@ legacy_test (the executor behind the Legacy rerun), not f2f88c phase3: Output (--out, outside the checkout): signals.npz with sensors (N,6), forces (N,6), actions (N,3) in the f2f88c phase3 layout, so its comparator applies. - PYTHONPATH=src python research/karman_reproduce/run.py --dynamis /path/to/DynamisLab \\ - --config /path/to/config_lbm_pinball_legacy_compat.json --out /tmp/... [--device 0] + PYTHONPATH=src python research/karman_reproduce/run.py --dynamis DYN --model .../d1a3o12_re100.zip \\ + --norm .../karman_re100/norm.json --config .../config_lbm_pinball_legacy_compat.json \\ + --out /tmp/new-dir [--device 1] """ from __future__ import annotations @@ -44,7 +45,9 @@ def git_head(path): def main(): ap = argparse.ArgumentParser() - ap.add_argument("--dynamis", required=True, help="DynamisLab checkout (read-only)") + ap.add_argument("--dynamis", required=True, help="DynamisLab checkout (imported read-only)") + ap.add_argument("--model", required=True, help="frozen d1a3o12_re100.zip") + ap.add_argument("--norm", required=True, help="frozen karman_re100 norm.json") ap.add_argument("--config", required=True) ap.add_argument("--out", required=True) ap.add_argument("--device", type=int, default=0) @@ -55,12 +58,13 @@ def main(): raise SystemExit("--out must be outside the checkout") os.makedirs(args.out, exist_ok=True) + sys.dont_write_bytecode = True # import only: write nothing into the DynamisLab tree sys.path.insert(0, os.path.join(args.dynamis, "src")) - from drl_pinball.legacy_test.core.model_loader import load_model, model_path + from stable_baselines3 import PPO + from drl_pinball.legacy_test.core.model_loader import _dummy_env from drl_pinball.legacy_test.runtime import load_policy_norm, policy_observation - norm_path = os.path.join(args.dynamis, "src", "SR_analysis", "data", "karman", "karman_re100", - "norm.json") - model, norm = load_model("d1a3o12_re100"), load_policy_norm(norm_path) + model = PPO.load(args.model, env=_dummy_env(12), device="cpu") + norm = load_policy_norm(args.norm) from CelerisLab.simulation import Simulation sim = Simulation(args.config, device_id=args.device) @@ -97,8 +101,8 @@ def main(): forces=forces, actions=actions) with open(os.path.join(args.out, "case.json"), "w") as fh: json.dump(dict(celeris=git_head(here), dynamis=git_head(args.dynamis), - config=os.path.realpath(args.config), model=model_path("d1a3o12_re100"), - norm=norm_path, warmup=WARMUP, interval=SI, intervals=args.intervals, + config=os.path.realpath(args.config), model=os.path.realpath(args.model), + norm=os.path.realpath(args.norm), warmup=WARMUP, interval=SI, intervals=args.intervals, probe_cells=cells), fh, indent=1) finally: sim.close()