Commit db1bcc3
authored
Refactor: unify PTO-ISA resolve + auto-clone; add shared --log-level helper (#555)
PTO-ISA unification
-------------------
Before this change there were two parallel implementations of
"ensure PTO-ISA is available":
simpler_setup/pto_isa.py::ensure_pto_isa_root()
- Only looked up (env var -> default path), raised OSError if missing.
- Called by scene_test.py, so `pytest` and standalone `python test_*.py`
hit OSError on a fresh checkout, with an error message that literally
told the user to go run ci.py or run_example.py first. A real
onboarding papercut.
simpler_setup/code_runner.py::_ensure_pto_isa_root()
- Full clone + commit pin + lock + fetch-latest logic (~280 lines).
- Called by ci.py and run_example.py (via CodeRunner).
Unify both behind a single API in simpler_setup/pto_isa.py. All four user
entry points (pytest, standalone test_*.py, ci.py, run_example.py) now
auto-clone on first use.
Move default clone target
examples/scripts/_deps/pto-isa -> PROJECT_ROOT/build/pto-isa
- `build/` is the repo's canonical artifact directory (already gitignored,
already hosts `build/lib/` and `build/cache/`).
- Per-repo/worktree/venv isolation via PROJECT_ROOT means concurrent
worktrees each get their own clone and don't race on commit pins.
- One-time re-clone for existing dev machines; acceptable.
New signature:
ensure_pto_isa_root(
commit: Optional[str] = None,
clone_protocol: str = "ssh",
update_if_exists: bool = False, # fetch origin/HEAD when True + no commit
verbose: bool = False,
) -> str
- scene_test calls with defaults -> auto-clone on first run, never touch
an existing clone (no network on every pytest run).
- ci.py / CodeRunner pass update_if_exists=True + verbose=True to preserve
"always ensure latest" behaviour; commit pin still wins when provided.
code_runner.py loses ~280 lines of PTO-ISA code and the fcntl import;
ci.py updates its two import sites to reach pto_isa directly
(ensure_pto_isa_root, checkout_pto_isa_commit, get_pto_isa_clone_path).
The "Cloning pto-isa to X ..." heads-up is emitted at WARNING level so it
surfaces even in pytest / standalone paths that have no basicConfig —
otherwise users would see a 30-60s silent hang on first run.
Shared --log-level helper
-------------------------
Add simpler_setup/log_config.py exposing LOG_LEVEL_CHOICES,
DEFAULT_LOG_LEVEL ("info"), and configure_logging(log_level).
All three CLI entry points now share one spelling of the flag, all default
to INFO:
ci.py --log-level error|warn|info|debug
examples/scripts/run_example.py --log-level ... (plus -v / --silent shortcuts)
python test_*.py (run_module) --log-level ...
The helper also propagates PTO_LOG_LEVEL env so ci.py's runtime-isolation
subprocesses inherit the level.
pytest is untouched — it has its own --log-cli-level / pyproject log_cli_level
and doesn't need a layered flag.
Verification
------------
- pytest tests/ut/py: 121 passed, 5 skipped (unchanged from main)
- tools/verify_packaging.sh: all 5 install modes × 4 entry points green
- All 3 CLI entry points expose --log-level choices with default info1 parent 2a53df4 commit db1bcc3
6 files changed
Lines changed: 326 additions & 396 deletions
File tree
- examples/scripts
- simpler_setup
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
| 63 | + | |
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
| |||
72 | 70 | | |
73 | 71 | | |
74 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
75 | 77 | | |
76 | 78 | | |
77 | 79 | | |
| |||
264 | 266 | | |
265 | 267 | | |
266 | 268 | | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
277 | 280 | | |
278 | 281 | | |
279 | 282 | | |
| |||
952 | 955 | | |
953 | 956 | | |
954 | 957 | | |
955 | | - | |
| 958 | + | |
956 | 959 | | |
957 | | - | |
| 960 | + | |
958 | 961 | | |
959 | | - | |
| 962 | + | |
960 | 963 | | |
961 | 964 | | |
962 | 965 | | |
| |||
1177 | 1180 | | |
1178 | 1181 | | |
1179 | 1182 | | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1180 | 1186 | | |
1181 | 1187 | | |
1182 | 1188 | | |
| |||
1276 | 1282 | | |
1277 | 1283 | | |
1278 | 1284 | | |
1279 | | - | |
1280 | | - | |
1281 | 1285 | | |
| 1286 | + | |
1282 | 1287 | | |
1283 | 1288 | | |
1284 | 1289 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| |||
127 | 130 | | |
128 | 131 | | |
129 | 132 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | 133 | | |
144 | 134 | | |
145 | | - | |
146 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
147 | 138 | | |
148 | 139 | | |
149 | 140 | | |
| |||
206 | 197 | | |
207 | 198 | | |
208 | 199 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 200 | + | |
234 | 201 | | |
235 | 202 | | |
236 | 203 | | |
| |||
249 | 216 | | |
250 | 217 | | |
251 | 218 | | |
252 | | - | |
253 | 219 | | |
254 | | - | |
255 | | - | |
256 | 220 | | |
257 | 221 | | |
258 | 222 | | |
| |||
310 | 274 | | |
311 | 275 | | |
312 | 276 | | |
313 | | - | |
| 277 | + | |
314 | 278 | | |
315 | 279 | | |
316 | 280 | | |
317 | 281 | | |
318 | 282 | | |
319 | 283 | | |
320 | 284 | | |
321 | | - | |
322 | | - | |
| 285 | + | |
323 | 286 | | |
324 | 287 | | |
325 | 288 | | |
| |||
332 | 295 | | |
333 | 296 | | |
334 | 297 | | |
335 | | - | |
| 298 | + | |
336 | 299 | | |
337 | 300 | | |
338 | 301 | | |
| |||
0 commit comments