research: karman reproduce takes explicit model/norm paths; no bytecode written into DynamisLab
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f04036e4e4
commit
3c6c9c690a
1 file changed
+13
-9
@@ -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
|
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.
|
(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 \\
|
PYTHONPATH=src python research/karman_reproduce/run.py --dynamis DYN --model .../d1a3o12_re100.zip \\
|
||||||
--config /path/to/config_lbm_pinball_legacy_compat.json --out /tmp/... [--device 0]
|
--norm .../karman_re100/norm.json --config .../config_lbm_pinball_legacy_compat.json \\
|
||||||
|
--out /tmp/new-dir [--device 1]
|
||||||
"""
|
"""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
@@ -44,7 +45,9 @@ def git_head(path):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
ap = argparse.ArgumentParser()
|
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("--config", required=True)
|
||||||
ap.add_argument("--out", required=True)
|
ap.add_argument("--out", required=True)
|
||||||
ap.add_argument("--device", type=int, default=0)
|
ap.add_argument("--device", type=int, default=0)
|
||||||
@@ -55,12 +58,13 @@ def main():
|
|||||||
raise SystemExit("--out must be outside the checkout")
|
raise SystemExit("--out must be outside the checkout")
|
||||||
os.makedirs(args.out, exist_ok=True)
|
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"))
|
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
|
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",
|
model = PPO.load(args.model, env=_dummy_env(12), device="cpu")
|
||||||
"norm.json")
|
norm = load_policy_norm(args.norm)
|
||||||
model, norm = load_model("d1a3o12_re100"), load_policy_norm(norm_path)
|
|
||||||
|
|
||||||
from CelerisLab.simulation import Simulation
|
from CelerisLab.simulation import Simulation
|
||||||
sim = Simulation(args.config, device_id=args.device)
|
sim = Simulation(args.config, device_id=args.device)
|
||||||
@@ -97,8 +101,8 @@ def main():
|
|||||||
forces=forces, actions=actions)
|
forces=forces, actions=actions)
|
||||||
with open(os.path.join(args.out, "case.json"), "w") as fh:
|
with open(os.path.join(args.out, "case.json"), "w") as fh:
|
||||||
json.dump(dict(celeris=git_head(here), dynamis=git_head(args.dynamis),
|
json.dump(dict(celeris=git_head(here), dynamis=git_head(args.dynamis),
|
||||||
config=os.path.realpath(args.config), model=model_path("d1a3o12_re100"),
|
config=os.path.realpath(args.config), model=os.path.realpath(args.model),
|
||||||
norm=norm_path, warmup=WARMUP, interval=SI, intervals=args.intervals,
|
norm=os.path.realpath(args.norm), warmup=WARMUP, interval=SI, intervals=args.intervals,
|
||||||
probe_cells=cells), fh, indent=1)
|
probe_cells=cells), fh, indent=1)
|
||||||
finally:
|
finally:
|
||||||
sim.close()
|
sim.close()
|
||||||
|
|||||||
Reference in new issue
Block a user