Skip to content

Add POST /simulations/runs listing endpoint + convergence plan#48

Merged
jcschaff merged 2 commits into
mainfrom
feature/runs-api
May 29, 2026
Merged

Add POST /simulations/runs listing endpoint + convergence plan#48
jcschaff merged 2 commits into
mainfrom
feature/runs-api

Conversation

@jcschaff

Copy link
Copy Markdown
Contributor

Summary

Implements the simulation-runs listing endpoint (backend, full persist + query) from docs/simulation-runs-api-plan.md, and adds a sequenced plan for converging the duplicate run-execution paths.

POST /simulations/runs (new)

  • PersistenceSimulationRunRecord in a new BiosimSimulationRuns collection, written one-per-(submission × simulator) on POST /simulations/run at status=CREATED, then updated to SUCCEEDED/FAILED by SimulationRunWorkflow via a new update_run_status_activity. Internal processing/success/failure maps to the frontend's CREATED/SUCCEEDED/FAILED.
  • Query — owner-scope (type: all|user + user email), pagination, sorting, filtering. Returns { runs: SimulationRun[], pagination: { page, perPage, _total } }. Filter ids are allowlisted (also blocks arbitrary-field injection).
  • PlumbingSimulationRunDatabaseService (+ Mongo impl); DI getter wired via a lazy import to avoid the simulations → dependencies import cycle; new activity registered in worker_main.py and the test worker fixture.

Test-isolation fix

The shared database_service_mongo fixture never cleaned BiosimSims on teardown, so the real-network test_sim_workflow leaked a SUCCEEDED record that gave later tests a spurious cache hit (failing integration_local in the full suite). It now cleans up on teardown, matching its sibling omex_database_service_mongo.

Convergence plan (docs/simulation-runs-convergence-plan.md)

There are currently two implementations of "run one sim on biosimulations.org" (the verify path's OmexSimWorkflow + monolithic activity, and this path's split submit/poll activities). The doc lays out four independently-shippable PRs to converge them: re-expose cache_buster, enrich BiosimSimulationRun parsing, reuse OmexSimWorkflow as the single per-run unit, and normalize SimulationRunRecord to FK into BiosimulatorWorkflowRun with a join-backed listing.

Known limitations (documented)

  • Deferred fields (cpus, memory, maxTime, envVars, purpose, runtime, projectSize, resultsSize) default to 0/[] — the platform doesn't capture them yet (PR1 in the convergence plan sources them).
  • No real auth — owner-scoping trusts the supplied email.
  • Frontend follow-up: wire frontend/app/pages/simulations/index.vue (currently on mock data) to this endpoint.

Testing

  • ruff clean; mypy --strict clean (biosim_server + tests).
  • New tests/simulations/test_runs_query.py (query-translation unit tests, Mongo-backed service tests, endpoint tests) + end-to-end assertions in tests/integration_local/test_simulations_run.py — all pass.
  • Full poetry run pytest -m "not integration": 74 passed, 1 failed. The single failure is the pre-existing test_slurm_service (UnboundLocalError, needs SSH creds) — environmental, unrelated to this change.

🤖 Generated with Claude Code

HarrisonCreates and others added 2 commits May 22, 2026 14:42
Implements the runs listing endpoint (backend, full persist + query) from
docs/simulation-runs-api-plan.md:

- SimulationRunRecord persisted in a new BiosimSimulationRuns collection,
  written per (submission x simulator) on POST /simulations/run and updated
  to SUCCEEDED/FAILED by SimulationRunWorkflow via update_run_status_activity.
- POST /simulations/runs: owner-scope (type all|user), pagination, sorting,
  filtering; returns { runs, pagination: { page, perPage, _total } }.
- SimulationRunDatabaseService (+ Mongo impl), DI wired via lazy import to
  avoid the simulations->dependencies import cycle.
- Deferred fields (cpus/memory/maxTime/envVars/purpose/runtime/sizes) default
  to 0/[] until sourced upstream; no real auth (owner-scope trusts email).

Also fixes a latent test-isolation bug: the shared database_service_mongo
fixture now cleans BiosimSims on teardown, preventing the real-network
test_sim_workflow from leaking a record that gave later tests a spurious
cache hit.

Adds docs/simulation-runs-convergence-plan.md describing how to converge the
duplicate run-execution paths (reuse OmexSimWorkflow as the per-run unit,
normalize SimulationRunRecord to FK into BiosimulatorWorkflowRun, re-expose
cache_buster), sequenced as independently shippable PRs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jcschaff jcschaff merged commit d5b9317 into main May 29, 2026
5 checks passed
@jcschaff jcschaff deleted the feature/runs-api branch May 29, 2026 18:19
jcschaff added a commit that referenced this pull request May 29, 2026
Restores parity with /verify/omex, which exposes a cache_buster salt for the
(omex, simulator, cache_buster) result cache. The run endpoint had hardcoded
"0", silently forcing dedup across all submissions.

- RunSimulationRequest.cache_buster (optional); the router forwards it to the
  workflow input and persists it on SimulationRunRecord. Default "0" preserves
  the current dedup behavior; a caller-supplied salt forces fresh runs.
- Tests: an explicit salt is forwarded to the workflow input; omitting it
  defaults to "0"; cache_buster round-trips through Mongo.

PR0 of docs/simulation-runs-convergence-plan.md. Stacked on feature/runs-api
(depends on its SimulationRunRecord); retarget base to main after #48 merges.

Co-Authored-By: Claude Opus 4.7 (1M context) <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

None yet

Development

Successfully merging this pull request may close these issues.

2 participants