Skip to content

Commit c536e13

Browse files
JuliaEdomclaude
andcommitted
fix(namespace): restore repo-root sys.path bootstrap for path-invoked scripts
The editable install used to put the repository root on sys.path (packages=["src"] made the root the package parent), which silently made `import tests.*` / `import scripts.*` work for scripts invoked by path. The src-layout editable now exposes only <root>/src, so the three scripts that CI invokes by path and that import their own package (tests/load/run_load_test.py — Load Test workflow; scripts/backup.py — backup workflow; scripts/run_nl_sql_eval.py) bootstrap the root explicitly, same idiom as the other scripts. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent dc71290 commit c536e13

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

‎scripts/backup.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@
66
import json
77
import os
88
import shutil
9+
import sys
910
import tarfile
1011
import tempfile
1112
from dataclasses import asdict, dataclass
1213
from datetime import UTC, datetime
1314
from pathlib import Path
1415
from urllib.parse import urlparse
1516

17+
# F-09: invoked as `python scripts/<name>.py`, so the repository root must
18+
# be on sys.path for the `scripts.*` package import below.
19+
REPO_ROOT = Path(__file__).resolve().parents[1]
20+
if str(REPO_ROOT) not in sys.path:
21+
sys.path.insert(0, str(REPO_ROOT))
22+
1623
import duckdb
1724

1825
from scripts.check_release_artifacts import FORBIDDEN_MEMBER_PATTERNS

‎scripts/run_nl_sql_eval.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@
1212

1313
import argparse
1414
import os
15+
import sys
1516
from pathlib import Path
1617

18+
# F-09: invoked as `python scripts/<name>.py`, so the repository root must
19+
# be on sys.path for the `scripts.*` package import below.
20+
REPO_ROOT = Path(__file__).resolve().parents[1]
21+
if str(REPO_ROOT) not in sys.path:
22+
sys.path.insert(0, str(REPO_ROOT))
23+
1724
from scripts.nl_sql_eval import EvalReport, run_eval
1825

1926

‎tests/load/run_load_test.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
from datetime import UTC, datetime
1010
from pathlib import Path
1111

12+
# F-09: run as a script in CI (`python tests/load/run_load_test.py`), so the
13+
# repository root must be on sys.path for the `tests.load` import below.
14+
REPO_ROOT = Path(__file__).resolve().parents[2]
15+
if str(REPO_ROOT) not in sys.path:
16+
sys.path.insert(0, str(REPO_ROOT))
17+
1218
from tests.load.thresholds import LOAD_PROFILE, THRESHOLDS
1319

1420

0 commit comments

Comments
 (0)