Skip to content

PiWindPreAnalysis test_2: pa_dtype pre-analysis output read back from parquet - #68

Draft
sambles wants to merge 2 commits into
mainfrom
test/pre-analysis-pa-dtype-parquet
Draft

sambles wants to merge 2 commits into
mainfrom
test/pre-analysis-pa-dtype-parquet

Conversation

@sambles

@sambles sambles commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Reproduces OasisLMF/ODS_Tools#324.

Important

Do not merge until OasisLMF/ODS_Tools#324 is fixed. This test fails on purpose with current ods-tools (5.0.6 and later), so CI is expected to be red on this PR until the fix is released and picked up.

What it adds

PiWindPreAnalysis/tests/test_2 runs PiWind (first 20 locations) with:

  • "oed_backend_dtype": "pa_dtype";
  • a pre-analysis hook that needs no external service, src/exposure_modification/exposure_pre_analysis_tiv.py (BuildingTIV x2);
  • a pre-loss hook, src/pre_loss/pre_loss_check_exposure.py, that reloads the exposure saved in the run's input/ folder.

oasislmf saves the pre-analysis output as parquet. With pa_dtype, ods-tools (#277) dictionary-encodes low-cardinality string columns as pd.ArrowDtype(pa.dictionary(...)), and pandas can't read those back from parquet:

TypeError: data type 'dictionary<values=large_string, indices=int8, ordered=0>[pyarrow]' not understood

Within one oasislmf model run the exposure is passed between steps in memory, so the saved files are never read back. The Oasis platform runs the steps as separate tasks and does read them back. The pre-loss hook reloads them from disk to cover that case. test_2/README.md has the details and the CLI repro.

expected_results/ comes from the same run with --oed-backend-dtype pd_dtype. In a PiWind comparison, the pd_dtype and pa_dtype loss outputs were byte-for-byte identical.

Other changes

  • tests/test_model_runs.py: the skip now names only PiWindPreAnalysis/test_1 (it needs the Precisely geocoding API), not the whole model, so test_2 runs.
  • PiWindPreAnalysis/model_data: added the missing event data (events_p.bin, occurrence_lt.bin, damage_bin_dict.bin, quantile.bin, returnperiods.bin, vulnerability.bin). Without it no test of this model could run. The files are copied from PiWindPostcode, whose other model and keys data files are identical. They are force-added past the *.bin gitignore, as PiWindPostcode does.

Testing

Environment test_2
oasislmf 2.5.9, ods-tools 5.0.10, pandas 3.1.0 (coreoasis/model_worker:2.5.9) ❌ fails as expected, test_1 skipped
oasislmf 2.5.9, ods-tools 5.0.10, pandas 3.1.1 ❌ fails as expected
ods-tools before #277 (no dictionary encoding) ✅ passes
--oed-backend-dtype pd_dtype ✅ passes, outputs match expected_results/

🤖 Generated with Claude Code

sambles and others added 2 commits November 24, 2026 10:48
…sions

PiWindPreAnalysis/model_data had no event set (events_p.bin, occurrence_lt.bin, ...),
so no test of this model could run. Copied from PiWindPostcode, whose other model and
keys data files are identical. *.bin is gitignored, so these are force-added as in
PiWindPostcode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant