Skip to content

Commit b72ac3f

Browse files
anth-volkclaude
andcommitted
Split the Stage 12 runtime tests into smaller files
tests/test_stage12_runtime.py (4,709 lines) was over the file-length limit for test code. Its tests move, unchanged, into thirteen files by behaviour: - test_stage12_runtime.py: loading a simulation's dataset and region - test_stage12_dataset_provenance.py: the dataset a calculation loads - test_stage12_single_worker.py, test_stage12_single_worker_failures.py - test_stage12_aggregate_reports.py - test_stage12_coordinator.py, test_stage12_coordinator_failures.py, test_stage12_coordinator_failure_records.py - test_stage12_runtime_store_retries.py - test_stage12_child_cancellation.py, test_stage12_child_state_errors.py - test_stage12_wait_window.py The helpers several files use move to three support modules: stage12_runtime_support.py (inputs, records, runtimes and failure checks), stage12_fake_stores.py (the in-memory stores) and stage12_child_call_support.py (fake child calls and invokers). Their private names are now public, under names that no test uses for a local variable: for example _report is report_execution_input, _simulation is simulation_execution_input, _context is invocation_context and _parent is parent_record. The seven other Stage 12 test modules that imported them from test_stage12_runtime.py now import them from the support modules, and coordinate_report_impl from the package itself. All 1,895 tests keep their names and bodies, apart from the renamed helpers. Pytest names two parametrized cases of test_installed_bundle_accepts_the_dataset_a_region_loads after the bundle helper, so they are now [us-bundle_provenance] and [state/ut-bundle_provenance]. The file-length baseline drops the file (count 8 to 7). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 45c5ed8 commit b72ac3f

26 files changed

Lines changed: 4885 additions & 4510 deletions

‎changelog_entry.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- Ran Stage 12 US national simulations as 20 region-group calls each, and built an independent, immutable Stage 12 cache of three annual US datasets and 60 current-law baselines before each deployment, publishing it only after a recorded determinism check and recording its release in the v2 version manifest under a new key, while the existing key keeps a copy that earlier readers accept
1717
- Made the budget refuse a household count outside its country's plausible range (above 200 million in the US or 60 million in the UK, negative or not finite), raising ImplausibleEntityCountError instead of publishing a count like #767's
1818
changed:
19+
- Split the 4,709-line Stage 12 runtime test file into thirteen test files by behaviour (dataset loading, provenance, the single worker and its failures, aggregates, the coordinator and its failures, runtime store retries, failure records, cancellation, child state errors and the wait window) and three support modules for the shared builders, fake stores and fake child calls, whose helpers are now public; the other Stage 12 tests import them from those modules, every test keeps its name and body, and two parametrized cases are named after the renamed bundle helper
1920
- Split Stage 12 report coordination (stage12_runtime/coordination.py, 1,091 lines) into modules for the report coordinator class, its child simulations' records, failures and cancellation, and the parent report's checks and claim, with coordinate_report and every public name still in coordination.py and child failures still logged under its logger; and turned the contract's stage12_execution.py (929 lines) into a stage12_execution package of modules for the shared field types and simulation input, report inputs and output plans, result artifacts, and comparison-run records, which re-exports every name from the same import path, with unchanged JSON schemas; models subclass the base models through the package path ruff.toml lists, so no ruff setting changes
2021
- Split the gateway's endpoints.py (1,454 lines) into modules for the shared router and request helpers, route resolution from the active routing state, Modal reads of job metadata and routing, bundle payloads, and the job submission, job status and version routes, which register their routes in the same order, so the OpenAPI document is unchanged; endpoints.py re-exports every public name, the routes keep logging under the policyengine_simulation_gateway.endpoints logger, and the private helpers the new modules share are now public; its 1,801-line test file is split into five test files, with the shared expected-response helpers in fixtures/gateway_responses.py
2122
- Split the routing publisher (src/modal/utils/update_version_registry.py, 1,584 lines) into a src/modal/routing_publisher package of modules for the bundle manifest, the routing state, routing plans and their publication record, the check that only serialized workflows write routing, Modal Dict access, plan publication, the legacy seed and the command-line options, and its 2,728-line test file into a tests/version_registry directory of nine test files with shared fixtures; update_version_registry.py keeps the command line, still runs with python -m src.modal.utils.update_version_registry and re-exports every public name; behaviour and output are unchanged, and the private helpers the new modules share are now public

‎docs/generated/rules.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Every rule that governs `policyengine-sim-api` is listed here with how it is enf
6666

6767
- `sim.ci.multiline-run-is-script`: 13 remaining in `rules/baselines/ci-multiline-run.txt`
6868
- `sim.microdata.weight-stripping-confined`: 0 remaining in `rules/baselines/sim-microdata-weight-stripping.txt`
69-
- `sim.quality.python-file-length`: 8 remaining in `rules/baselines/python-file-length.txt`
69+
- `sim.quality.python-file-length`: 7 remaining in `rules/baselines/python-file-length.txt`
7070

7171
### Exceptions and review dates
7272

0 commit comments

Comments
 (0)