Skip to content

Commit 4375df7

Browse files
baogorekclaude
andcommitted
Fix ModuleNotFoundError: add sys.path setup before modal_app.images import
Modal containers don't have the repo root on sys.path by default, so `from modal_app.images import ...` fails. Add the same sys.path fix that pipeline.py already uses for its cross-module imports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a094158 commit 4375df7

4 files changed

Lines changed: 33 additions & 0 deletions

File tree

modal_app/data_build.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111

1212
import modal
1313

14+
import sys as _sys
15+
from pathlib import Path as _Path
16+
17+
_baked = "/root/policyengine-us-data"
18+
_local = str(_Path(__file__).resolve().parent.parent)
19+
for _p in (_baked, _local):
20+
if _p not in _sys.path:
21+
_sys.path.insert(0, _p)
22+
1423
from modal_app.images import cpu_image as image
1524

1625
app = modal.App("policyengine-us-data")

modal_app/local_area.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@
1818
from pathlib import Path
1919
from typing import List, Dict
2020

21+
import sys as _sys
22+
23+
_baked = "/root/policyengine-us-data"
24+
_local = str(Path(__file__).resolve().parent.parent)
25+
for _p in (_baked, _local):
26+
if _p not in _sys.path:
27+
_sys.path.insert(0, _p)
28+
2129
from modal_app.images import cpu_image as image
2230

2331
app = modal.App("policyengine-us-data-local-area")

modal_app/pipeline.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@
4444
from typing import Optional
4545

4646
import modal
47+
import sys as _sys
48+
49+
_baked = "/root/policyengine-us-data"
50+
_local = str(Path(__file__).resolve().parent.parent)
51+
for _p in (_baked, _local):
52+
if _p not in _sys.path:
53+
_sys.path.insert(0, _p)
4754

4855
from modal_app.images import cpu_image as image
4956

modal_app/remote_calibration_runner.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
import subprocess
33
import modal
44

5+
import sys as _sys
6+
from pathlib import Path as _Path
7+
8+
_baked = "/root/policyengine-us-data"
9+
_local = str(_Path(__file__).resolve().parent.parent)
10+
for _p in (_baked, _local):
11+
if _p not in _sys.path:
12+
_sys.path.insert(0, _p)
13+
514
from modal_app.images import gpu_image as image
615

716
app = modal.App("policyengine-us-data-fit-weights")

0 commit comments

Comments
 (0)