56 lines
2.0 KiB
Python
56 lines
2.0 KiB
Python
"""Keep the accepted GINO measurement and bind it to the approved idle V100."""
|
|
|
|
import argparse
|
|
from copy import deepcopy
|
|
from pathlib import Path
|
|
from types import FunctionType
|
|
|
|
import track_b_gino_import_checked_entry as checked_entry
|
|
from track_b_gino_shapenet_entry import checked, read, sha
|
|
|
|
|
|
ROOT = checked_entry.ROOT.with_name("track-b-gino-shapenet611-gpu2-measurement-2026-11-19")
|
|
ENTRY = Path(__file__).resolve()
|
|
WORKER = ENTRY.with_name("track_b_gino_measurement_gpu2_worker.py")
|
|
UUID = "GPU-b8c11c01-c91f-aa0b-abf6-dad35085cc76"
|
|
PRIOR_CONTRACT = "ab97357150578ea649140a5be01ed5639edcd998874d3788dc9bf8a42acac28e"
|
|
|
|
|
|
def expected_contract():
|
|
c = deepcopy(read(checked(checked_entry.ROOT / "contract.json", PRIOR_CONTRACT)))
|
|
c["gpu_uuid"] = UUID
|
|
c["gpu_ruling"] = "h-bc42181f"
|
|
c["code_sha256"].update({str(p): sha(p) for p in (ENTRY, WORKER)})
|
|
return c
|
|
|
|
|
|
def contract(path):
|
|
c = checked_entry.contract(path)
|
|
if c != expected_contract():
|
|
raise PermissionError("Only the accepted measurement retargeted to GPU2 is authorized")
|
|
return c
|
|
|
|
|
|
def dispatch_guard(root, path):
|
|
namespace = dict(checked_entry.dispatch_guard.__globals__, contract=contract, WORKER=WORKER)
|
|
return FunctionType(checked_entry.dispatch_guard.__code__, namespace, "dispatch_guard")(root, path)
|
|
|
|
|
|
def authorized_child(root):
|
|
namespace = dict(checked_entry.authorized_child.__globals__, ROOT=ROOT, contract=contract)
|
|
return FunctionType(checked_entry.authorized_child.__code__, namespace, "authorized_child")(root)
|
|
|
|
|
|
def run(root):
|
|
if (checked_entry.ROOT / "started.json").exists():
|
|
raise FileExistsError("Previous accepted entry already has a start record")
|
|
namespace = dict(checked_entry.run.__globals__, ROOT=ROOT, contract=contract,
|
|
dispatch_guard=dispatch_guard)
|
|
return FunctionType(checked_entry.run.__code__, namespace, "run")(root)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("root", type=Path)
|
|
raise SystemExit(run(parser.parse_args().root))
|