Skip to content

Platform testing on OasisModels - #65

Merged
sambles merged 33 commits into
mainfrom
feature/platform-tests
Nov 25, 2026
Merged

sambles merged 33 commits into
mainfrom
feature/platform-tests

Conversation

@sambles

@sambles sambles commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Revert before merging: for testing only, .github/workflows/platform-tests.yml builds the platform images from the OasisPlatform branch fix/oasis-models-testing (job platform-images, PLATFORM_BRANCH default, marked TODO). That branch has the platform fixes these tests found. Set the default back to main before this PR is merged.

Runs the OasisModels test cases through a real OasisPlatform (API server + workers) as well as the MDK. Replaces PiWind's test_piwind_integration action: each case's portfolio goes through input generation and losses on the platform, and the outputs are compared with the same expected_results/output the MDK tests use.

How it works

tests/test_platform_runs.py starts a minimal platform stack with testcontainers' DockerCompose for the whole session, then runs each selected case through the API with the oasislmf APIClient.

  • tests/compose/docker-compose.platform.yml: shared stack (server, server/celery DBs, RabbitMQ broker, v1 or v2 worker monitor) chosen with compose profiles:
    • API v1 / v2, database postgres / mysql (mysql.env), storage shared-fs / s3 (moto, s3.env).
    • Not included: websocket / channel layer (workers send progress over HTTP with OASIS_ANALYSIS_STATUS_URL) and celery-beat.
  • Per model, <Model>/docker/worker-container.yml extends the stack's worker template with the model id and data mounts. One worker is started per selected model. Each worker self-registers as OasisLMF/<Model>/<api-version>.
  • Per model, <Model>/docker-compose.yml + .env run the same stack by hand: cd PiWind && docker compose up -d --wait. The old docker/docker-compose*.yml files are removed.
  • Custom images: PiWindComplexModel and ComplexModelAPI build a worker image from docker/Dockerfile (installs complex_model_wrapper on top of the given worker image).
  • Fixed chunking on v2 (4 lookup / 4 analysis chunks) so results don't depend on platform defaults.
  • Result checks: platform runs always compare against expected_results/output (rel. tolerance 1e-4), ignoring analysis_settings.json and the platform-only combine/ dir. --update-results regenerates them.
  • Shared discovery: tests/model_discovery.py (test cases, skip lists, env.json) is now used by both test_model_runs.py and test_platform_runs.py.

Test-only process limits

Every celery / gunicorn container defaults to one process per CPU. With 13 model workers on a 16-core machine that was 164 celery processes and the run was OOM-killed. tests/platform_stack.py sets, for tests only:

Processes
model worker (celery) 4
worker monitor (celery) 1
API server (gunicorn, docker-compose.test-limits.yml) 2

A plain docker compose up in a model folder keeps the image defaults. Worker task retries are set to 0 so failures surface at once (takes effect in images that include OasisPlatform#1521, merged after 2.5.9).

Running

pytest tests/test_platform_runs.py                               # PiWind/test_1, v2
pytest tests/test_platform_runs.py --platform-tests all          # every enabled case
pytest tests/test_platform_runs.py --platform-tests PiWind,PiWindBI/test_1 \
    --api-version v1 --db mysql --storage s3 \
    --server-image coreoasis/api_server:2.5.9 --worker-image coreoasis/model_worker:2.5.9

The file is only collected when passed explicitly or with --platform-tests, so a plain pytest doesn't start containers. Container logs, the generated stack config and each case's inputs / outputs / run logs go to --platform-logs.

Workflow: .github/workflows/platform-tests.yml

  • Triggers: pull_request (develop, main), workflow_dispatch, workflow_call. All run every enabled case by default; platform_tests selects a subset.
  • Reusable from other repos (e.g. OasisPlatform) to check newly built images. Inputs match OasisPiWind's integration.yml: server_image/server_tag, worker_image/worker_tag, worker_api_ver, db, storage, debug_mode, oasislmf_branch, pytest_opts, plus models_branch and storage_suffix for callers.
  • Uploads two artifacts: platform-logs (container logs + stack config) and platform-runs (per-case inputs, outputs and run logs).
  • model-tests.yml: passes GITHUB_TOKEN to the ODS_Tools git install, which lists OED spec release tags through the GitHub API and was hitting the unauthenticated rate limit.

Model changes

  • RI disabled (ri_output: false) in 9 cases whose tests have no RI files. The MDK only warns about this, but the platform errors: DeterministicModel/test_1, PiWindAbsoluteDamage/test_1–2, PiWindComplexModel/test_2, PiWindPostLossAmplification/test_1, PiWindSinglePeril/test_1, PiWindVulnerability/test_1–3.
  • Complex models (PiWindComplexModel, ComplexModelAPI): the supplier model runners now provide run_analysis / run_outputs for v2 chunked runs, and the custom gulcalc is set with model_custom_gulcalc in the worker's oasislmf.json.
  • PiWindComplexModel, DynamicFootprint: also mount PiWind/model_data, which their model_data symlinks point to.
  • PiWindDtype: worker sets OASIS_INT=i8, OASIS_FLOAT=f8, OASIS_AREAPERIL_TYPE=u8 (same as tests/test_1/env.json).
  • Client: a location file is no longer required (PiCyber runs from accounts only).

Platform status

12 cases enabled. On 2.5.9 images (v2, postgres, shared-fs), 11 of them passed locally in ~16 min. PiWindDtype was failing before its env var fix and hasn't been re-run on the platform since. The GitHub runner (4 vCPU) is roughly 3× slower than local.

Skipped on the platform (PLATFORM_SKIP_REASONS), on top of the MDK skip list:

  • Waiting on upstream fixes
  • Can't run on a shared worker config
    • PiWindComplexModel/test_2: tests implicit model runner discovery (no model_package_dir).
    • PiWindPostcode/test_4: its exposure pre-analysis settings file lives in the test directory.
  • test_1 only per model, to keep run time down: PiWindAbsoluteDamage/test_2, PiWindPostcode/test_2, test_3, test_5, PiWindVulnerability/test_2, test_3, UKWind/test_2.

Related upstream

🤖 Generated with Claude Code

sambles and others added 27 commits November 18, 2026 09:57
- .github/workflows/platform-tests.yml: reusable (workflow_call) and
  manual platform test workflow, taking server/worker images to test
  (same inputs as OasisPiWind's integration.yml). PRs run PiWind/test_1.
- Complex model runners: add run_outputs() (needed for distributed v2
  runs) and return results; set model_custom_gulcalc in the workers'
  oasislmf.json so v2 loss chunks use the custom gulcalc.
- Skip PiWindComplexModel/test_2 on the platform (implicit runner
  discovery can't be expressed with the shared worker config).
- Log server requests in the test stack (gunicorn access log).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The model data is built with OASIS_INT=i8, OASIS_FLOAT=f8 and
OASIS_AREAPERIL_TYPE=u8 (as in tests/test_1/env.json). Without them the worker
read the vulnerability file with the default types and failed with
"vulnerability_id 2 has damage_bin_id bigger that expected maximum".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sambles and others added 3 commits November 20, 2026 13:28
- Optional redis channel layer in the platform stack (compose profile
  `channel-layer`, pytest --channel-layer, workflow input channel_layer).
  Servers before 2.5.7 always send queue status through it and fail
  generate_inputs with a 500 without one.
- Inner job name is just the stack (api, db, storage), callers' job names
  say what's being checked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# TODO: testing only, set back to 'main' before OasisModels#65 is merged
# (fix/oasis-models-testing has the OasisPlatform fixes these tests found)
PLATFORM_BRANCH: ${{ inputs.platform_branch || 'fix/oasis-models-testing' }}
OASISLMF_REF: ${{ inputs.oasislmf_branch || 'fix/default-samples-distributed' }}

@Ha-Ree Ha-Ree Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pr desc says these need to be changed before release

Comment thread tests/test_platform_runs.py Outdated
"DynamicFootprint/test_1", # gulmc dynamic footprint
"PiCyber/test_1", # other peril / class of business, accounts-only portfolio
"PiWindDtype/test_1", # 64-bit dtypes (OASIS_INT / OASIS_FLOAT / OASIS_AREAPERIL_TYPE)
"PiWindS3/test_1", # (skipped at the moment pending a fix)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update comment

@sambles
sambles requested a review from Ha-Ree November 24, 2026 15:13

@Ha-Ree Ha-Ree left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to go when partner pr is in

@sambles
sambles merged commit 73af2e4 into main Nov 25, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Migrate PiWind testing to OasisModels

2 participants