File size: 1,734 Bytes
d8290eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""One selection binds the adapter, predictor and policy for real and sim runs."""

from dataclasses import dataclass
from pathlib import Path

PROJECT_ROOT = Path(__file__).resolve().parents[1]


@dataclass(frozen=True)
class DeploymentBundle:
    velocity: str
    predictor: str
    policy_key: str
    notice_policy: str = "stage-b"
    generation_trigger_tth_s: float | None = None

    @property
    def policy_path(self) -> Path:
        return PROJECT_ROOT / self.policy_key


DEPLOYMENTS = {
    "original": DeploymentBundle("original", "original", "policies/h2/h2_stageC_model_10500.onnx"),
    "v1": DeploymentBundle("physics-ls-v1", "rk4-v1", "policies/h2/h2_real_v1_model_8998.onnx", "curriculum", 0.55),
    "v2": DeploymentBundle("physics-ls-v2", "rk4-v2", "policies/h2/h2_tail_v2_model_9997.onnx", "curriculum", 0.55),
}


def deployment_bundle(version: str) -> DeploymentBundle:
    try:
        return DEPLOYMENTS[version]
    except KeyError:
        raise ValueError(f"unknown deployment version: {version!r}; choose original|v1|v2") from None


if __name__ == "__main__":
    import argparse
    import shlex

    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("version", choices=DEPLOYMENTS)
    args = parser.parse_args()
    bundle = deployment_bundle(args.version)
    # Only fixed local values are emitted; launchers evaluate these assignments.
    for name, value in {
        "H2_DEPLOYMENT_VERSION": args.version,
        "H2_VELOCITY_VERSION": bundle.velocity,
        "H2_PREDICTOR_VERSION": bundle.predictor,
        "H2_POLICY_PATH": str(bundle.policy_path),
        "H2_NOTICE_POLICY": bundle.notice_policy,
    }.items():
        print(f"{name}={shlex.quote(value)}")