Repository navigation
Commit 8f87202
Remove the None presets and checks around Stage 12 span and operation blocks
Before policyengine-observability 3.0.4, Pyright read the span and
operation scopes as possibly suppressing the exception raised in their
block. #712 therefore set each value a block assigns to None before the
block and raised a RuntimeError after it when the value was still None.
3.0.4 annotates the scopes' __exit__ and __aexit__ as returning
Literal[False], and they return False on every path, so the block either
assigns its value or its exception reaches the caller. None of the
assigned values can be None either:
- v2_app.py: run_single_simulation_segment_us returns
calculate_segment(...).model_dump(mode="python"), a dict;
run_single_simulation_us and run_single_simulation_uk return
run_single_simulation(...), and coordinate_report returns
coordinate_report(...), both typed dict[str, Any], and every path of
each returns a dict or raises. Each function now returns from inside
its operation block (ruff's RET504 rejects assigning and then
returning); the operation still ends, and the runtime still shuts
down, before the function returns.
- fanout.py: the dispatched call is the FunctionCall that modal 1.4.2's
Function.spawn creates and returns on every path (it raises for a
generator function, and the segment function is not one), so
_require_call, the only check of it, is removed with the preset;
_collect returns a list or raises; and merge_segment_results returns a
SimulationCalculation, now from inside the merge span.
The removed RuntimeErrors could not be raised, so behaviour is unchanged
and there is no failing test to write: the tests added in the previous
commit, which run each block through the real runtime scopes, pass
before and after. Pyright still reports no errors in the executor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>1 parent 324e20f commit 8f87202
3 files changed
Lines changed: 7 additions & 44 deletions
File tree
- projects/policyengine-simulation-executor/src
- modal
- policyengine_simulation_executor/stage12_runtime
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
282 | | - | |
283 | 282 | | |
284 | 283 | | |
285 | 284 | | |
| |||
289 | 288 | | |
290 | 289 | | |
291 | 290 | | |
292 | | - | |
| 291 | + | |
293 | 292 | | |
294 | 293 | | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | 294 | | |
300 | 295 | | |
301 | 296 | | |
| |||
336 | 331 | | |
337 | 332 | | |
338 | 333 | | |
339 | | - | |
340 | 334 | | |
341 | 335 | | |
342 | 336 | | |
| |||
345 | 339 | | |
346 | 340 | | |
347 | 341 | | |
348 | | - | |
| 342 | + | |
349 | 343 | | |
350 | 344 | | |
351 | 345 | | |
| |||
354 | 348 | | |
355 | 349 | | |
356 | 350 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | 351 | | |
362 | 352 | | |
363 | 353 | | |
| |||
386 | 376 | | |
387 | 377 | | |
388 | 378 | | |
389 | | - | |
390 | 379 | | |
391 | 380 | | |
392 | 381 | | |
| |||
395 | 384 | | |
396 | 385 | | |
397 | 386 | | |
398 | | - | |
| 387 | + | |
399 | 388 | | |
400 | 389 | | |
401 | 390 | | |
402 | 391 | | |
403 | 392 | | |
404 | 393 | | |
405 | 394 | | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | 395 | | |
411 | 396 | | |
412 | 397 | | |
| |||
452 | 437 | | |
453 | 438 | | |
454 | 439 | | |
455 | | - | |
456 | 440 | | |
457 | 441 | | |
458 | 442 | | |
| |||
465 | 449 | | |
466 | 450 | | |
467 | 451 | | |
468 | | - | |
| 452 | + | |
469 | 453 | | |
470 | 454 | | |
471 | 455 | | |
| |||
475 | 459 | | |
476 | 460 | | |
477 | 461 | | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | 462 | | |
483 | 463 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | 45 | | |
54 | 46 | | |
55 | 47 | | |
| |||
130 | 122 | | |
131 | 123 | | |
132 | 124 | | |
133 | | - | |
134 | 125 | | |
135 | 126 | | |
136 | 127 | | |
| |||
139 | 130 | | |
140 | 131 | | |
141 | 132 | | |
142 | | - | |
| 133 | + | |
143 | 134 | | |
144 | 135 | | |
145 | 136 | | |
146 | 137 | | |
147 | | - | |
148 | 138 | | |
149 | 139 | | |
150 | 140 | | |
151 | 141 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | 142 | | |
157 | 143 | | |
158 | 144 | | |
159 | | - | |
| 145 | + | |
160 | 146 | | |
161 | 147 | | |
162 | 148 | | |
163 | 149 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
168 | 150 | | |
169 | 151 | | |
170 | 152 | | |
| |||
0 commit comments