vincewin commited on
Commit
71616ca
·
verified ·
1 Parent(s): f7afe09

deploy CREST_AI f82dec5: pin crestimap c5184759

Browse files
Files changed (1) hide show
  1. app.py +28 -10
app.py CHANGED
@@ -40,22 +40,40 @@ import traceback
40
  APP = os.path.dirname(os.path.abspath(__file__))
41
  FORK = "https://github.com/mchen15ouedu/CREST-iMAP.git"
42
  CREST_AI = "https://huggingface.co/spaces/vincewin/CREST_demo"
 
 
 
 
 
 
43
 
44
 
45
- def _bootstrap():
46
- """Blobless sparse clones: crestimap/ from the fork's v2, hf_data/ from
47
- the CREST_demo Space (eventsim/eventstore reuse — nothing reimplemented).
 
48
 
49
- crestimap is imported straight from the clone (kept as a git checkout), so
50
- provenance.stamp() records the fork SHA on every manifest; a copied-out
51
- package has no .git and stamped only "2.0.0.dev0"."""
 
 
 
 
 
 
52
  fork = os.path.join(APP, "_fork")
53
  if not os.path.isdir(os.path.join(fork, "crestimap")):
54
  shutil.rmtree(fork, ignore_errors=True)
55
- subprocess.run(["git", "clone", "--filter=blob:none", "--no-checkout",
56
- "-b", "v2", FORK, fork], check=True)
57
- subprocess.run(["git", "checkout", "HEAD", "--", "crestimap"],
58
- cwd=fork, check=True)
 
 
 
 
 
59
  if fork not in sys.path:
60
  sys.path.insert(0, fork)
61
  ai = os.path.join(APP, "_crest_ai")
 
40
  APP = os.path.dirname(os.path.abspath(__file__))
41
  FORK = "https://github.com/mchen15ouedu/CREST-iMAP.git"
42
  CREST_AI = "https://huggingface.co/spaces/vincewin/CREST_demo"
43
+ # Solver commit, pinned like the CPU Spaces' Dockerfile CRESTIMAP_REF and the
44
+ # Jetstream2 kit's FORK_REF: a push to v2 must never reach this worker on a
45
+ # restart without review. c5184759 = draining-time outflow limiter +
46
+ # interflow store, approved 2026-10-20. Full SHA only (a branch would float).
47
+ FORK_REF = os.environ.get("CRESTIMAP_REF",
48
+ "c518475956c933a9c0fc46962b3825685a54b181")
49
 
50
 
51
+ def _git(*args, cwd=None):
52
+ return subprocess.run(["git", *args], cwd=cwd, check=True,
53
+ capture_output=True, text=True).stdout.strip()
54
+
55
 
56
+ def _bootstrap():
57
+ """Blobless sparse clones: crestimap/ from the fork at FORK_REF, hf_data/
58
+ from the CREST_demo Space (eventsim/eventstore reuse — nothing
59
+ reimplemented).
60
+
61
+ crestimap is imported straight from the clone (a detached sparse checkout
62
+ of FORK_REF), so provenance.stamp() records the pinned SHA on every
63
+ manifest; a copied-out package has no .git and stamped only
64
+ "2.0.0.dev0"."""
65
  fork = os.path.join(APP, "_fork")
66
  if not os.path.isdir(os.path.join(fork, "crestimap")):
67
  shutil.rmtree(fork, ignore_errors=True)
68
+ # all branches are fetched (blobless), so a pinned commit stays
69
+ # reachable whichever branch carries it
70
+ _git("clone", "--filter=blob:none", "--no-checkout", FORK, fork)
71
+ _git("sparse-checkout", "init", "--cone", cwd=fork)
72
+ _git("sparse-checkout", "set", "crestimap", cwd=fork)
73
+ _git("checkout", "--detach", FORK_REF, cwd=fork)
74
+ want = _git("rev-parse", "--verify", f"{FORK_REF}^{{commit}}", cwd=fork)
75
+ if _git("rev-parse", "HEAD", cwd=fork) != want:
76
+ raise RuntimeError(f"crestimap clone is not at the pinned {FORK_REF}")
77
  if fork not in sys.path:
78
  sys.path.insert(0, fork)
79
  ai = os.path.join(APP, "_crest_ai")