Repository navigation
refactor(api): build the model pages on climate-ref's filters - #156
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Era-scoped ensemble values backend/src/ref_backend/core/mip_eras.py, backend/src/ref_backend/core/model_ensemble.py, backend/tests/perf/test_endpoints.py |
Ensemble queries now select latest scalar model values with era scoping and optional diagnostic-slug filtering. The performance allowlist includes ensemble endpoints. |
Execution-group model runs backend/src/ref_backend/core/model_runs.py, backend/tests/test_core/test_model_runs.py, backend/tests/perf/test_endpoints.py, changelog/156.improvement.md |
Model-run rows now aggregate distinct execution groups by source ID, diagnostic ID and outcome. failed_runs selects groups with a failure filter and returns failed or running labels for rows with executions. Tests and performance allowlists cover the updated query shape and model endpoints; the changelog records the endpoint changes. |
Sequence Diagram(s)
sequenceDiagram
participant model_run_rows
participant _model_groups
participant select_execution_group_ids
model_run_rows->>_model_groups: request model-run rows
_model_groups->>select_execution_group_ids: select groups with era and execution filters
select_execution_group_ids-->>_model_groups: return filtered group IDs
_model_groups-->>model_run_rows: return group and execution rows
model_run_rows->>model_run_rows: count distinct groups by source, diagnostic, and outcome
Possibly related PRs
- Climate-REF/ref-app#147: Introduced query builders and filters that this change uses and extends.
- Climate-REF/ref-app#145: Added the performance test suite and endpoint allowlists extended by this change.
Priority:
Change: Refactor
Merge Risk: 
Minimal · up to 3b511
-
The checked ensemble and model-run behavior remains consistent with the intended results. No identified issue blocks merging after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 76.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 5 files. (1 skipped: 1 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
The model list, model detail and ensemble pages now select through select_execution_group_ids, select_execution_groups and select_scalar_values. This drops their hand-built latest execution, promoted version and retraction joins, so the model pages count groups the same way as the diagnostics pages. The era scope comes from era_scope, as everywhere else.
The group filter looks up each group's latest execution per group, so a select per era did that twice and made /models 54% slower at full scale. Joining once to the model datasets of every era runs in half the time main took.
e02d46e to
748552c
Compare
Moves the models pages onto climate-ref's query builders and filters.
model_run_rows,failed_runsand the ensemble comparison now select throughselect_execution_group_ids,select_execution_groupsandselect_scalar_values. They no longer hand-build the latest execution, promoted version and retraction checks, so the models pages count groups the same way as the diagnostics pages.model_run_rowsjoins the filtered groups once to the model datasets of every era. A select per era looked up every group's latest execution again and made/models54% slower at full scale.failed_runsis nowExecutionGroupFilter(successful=False, input_datasets=...), ordered byupdated_at.MetricValueFilter(latest_only=True, dimensions={"kind": "model"}). A value with nokindnow counts as a model value, matching the reader.diagnostic_slugfilter moves from Python into SQL.era_group_clausesis gone. Every era scope now comes fromera_scope.Timings at full scale (
REF_PERF_SCALE=1), against main with only the 0.20.1 bump so both sides read the same database:models.list1082 → 594 ms,models.list.cmip6593 → 542 ms,models.get1394 → 1088 ms,models.get.cmip6893 → 362 ms,models.ensemble1449 → 1715 ms,models.ensemble.cmip6621 → 650 ms. At scale 0.5 the ensemble was 2% faster, so its full-scale number is likely noise. Every other endpoint was within 15%.The perf comparison on this PR builds the base's database with climate-ref 0.20.0, which has no group source types, so its numbers for the CMIP6 pages compare against empty results.
Summary by CodeRabbit