Skip to content

Commit 690fd54

Browse files
author
Ronald Tse
committed
fix(api): deterministic image mounts for the resolver + index
The add_local_dir layout doesn't put the repo root on sys.path; mount model_resolution.py and models.yaml at fixed paths instead.
1 parent 4322b49 commit 690fd54

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/api/inference.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@
1616

1717
models_volume = modal.Volume.from_name("secryst-models")
1818

19+
_REPO_ROOT = Path(__file__).resolve().parent.parent.parent
20+
1921
image = (
2022
modal.Image.debian_slim(python_version="3.11")
2123
.pip_install("onnxruntime==1.23.2", "pyyaml>=6.0", "fastapi>=0.115")
2224
.add_local_dir(str(Path(__file__).resolve().parent.parent), "/root/interscript-ml", copy=True)
25+
# deterministic mounts for the index-driven resolver + the index itself
26+
.add_local_file(str(Path(__file__).resolve().parent / "model_resolution.py"), "/root/model_resolution.py")
27+
.add_local_file(str(_REPO_ROOT / "models.yaml"), "/root/models.yaml")
2328
.workdir("/root/interscript-ml")
24-
.env({"IMAGE_REV": "5"})
29+
.env({"IMAGE_REV": "6"})
2530
)
2631

2732
app = modal.App("interscript-inference", image=image)
@@ -41,11 +46,11 @@ def _zip_path(model_id: str) -> Path:
4146
import os
4247
import sys
4348

44-
sys.path.insert(0, "/root/interscript-ml")
45-
from src.api.model_resolution import load_index, resolve_zip_filename
49+
sys.path.insert(0, "/root")
50+
from model_resolution import load_index, resolve_zip_filename
4651

4752
volume_files = [os.path.basename(z) for z in glob.glob("/v/imf/*/*.zip")]
48-
filename = resolve_zip_filename(model_id, load_index("models.yaml"), volume_files)
53+
filename = resolve_zip_filename(model_id, load_index("/root/models.yaml"), volume_files)
4954
for z in glob.glob(f"/v/imf/*/{filename}"):
5055
return Path(z)
5156
raise KeyError(model_id)

0 commit comments

Comments
 (0)