Skip to content

feat(results): share execution scope between value and resource filters - #977

Merged
lewisjared merged 8 commits into
mainfrom
feat/resources-latest-only
Oct 21, 2026
Merged

lewisjared merged 8 commits into
mainfrom
feat/resources-latest-only

Conversation

@lewisjared

@lewisjared lewisjared commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Adds latest_only and include_retracted to ResourceFilter, through a shared ExecutionScope that MetricValueFilter now uses too. One helper, apply_execution_scope, applies both to any select joined to Execution, so values, resources and DiagnosticsReader.with_values treat retraction and "latest" the same way.

The defaults answer how much compute was spent, retries and failures included. latest_only answers what one run of a diagnostic costs, because old retries no longer inflate the total and quick failures no longer drag down the mean. ref-app currently mixes the two: the diagnostic page totals every execution, while the catalog counts only the promoted version.

Retracted executions are excluded by default everywhere, unless a caller passes include_retracted=True. The one exception is ResourcesReader.measurement(execution_id), because a lookup by id names the execution.

Behaviour changes:

  • ResourcesReader.summary, summaries, measurements and profiles now skip retracted executions by default.
  • ResourcesReader.profiles accepts a ResourceFilter, so it takes latest_only, include_retracted and the exact slugs. The existing keyword arguments still work, but cannot be combined with a filter.
  • MetricValueFilter(diagnostic_slug="") now matches nothing, like ResourceFilter, instead of ignoring the slug.
  • MetricValueFilter(latest_only=True, include_retracted=True) now joins Execution. The rows returned are the same.

latest_only picks the latest execution before retracted ones are dropped. So if a group's newest execution is retracted, that group gives nothing unless include_retracted=True. It never falls back to an older execution, because the newer one superseded it. DatasetFilter drops retracted rows first instead, because an older dataset version is still valid.

Execution statistics and ExecutionsReader.groups still ignore retraction, because they report run status rather than results. ResourceFilter counts every diagnostic version. Nothing sets Execution.retracted yet, so none of this changes current output.

Allows resource summaries and measurements to count only each group's latest execution.
This answers what one run of a diagnostic costs, while the default still totals the compute spent.
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d8272fe5-e422-445e-aa34-67f95c1287bb
📥 Commits

Reviewing files that changed from the base of the PR and between 279a2ff and d4ae48c.

📒 Files selected for processing: 6
  • changelog/977.feature.md
  • packages/climate-ref/src/climate_ref/results/_query.py
  • packages/climate-ref/src/climate_ref/results/diagnostics.py
  • packages/climate-ref/src/climate_ref/results/resources.py
  • packages/climate-ref/tests/unit/results/test_resources.py
  • packages/climate-ref/tests/unit/results/test_results.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

ResourceFilter now shares execution-scope settings with metric queries. Resource queries include retracted executions by default and support latest-execution selection. Diagnostic queries retain their default exclusion of retracted executions. Tests cover these behaviours.

Changes: Execution-scope filtering

Layer / File(s) Summary
Define shared execution scope
packages/climate-ref/src/climate_ref/results/_query.py
Adds ExecutionScope and apply_execution_scope. MetricValueFilter inherits the shared settings, and common query filtering applies retraction and latest-execution constraints.
Apply scope to resource queries
packages/climate-ref/src/climate_ref/results/resources.py, packages/climate-ref/tests/unit/results/test_resources.py, changelog/977.feature.md
ResourceFilter inherits ExecutionScope and defaults include_retracted to True. Resource tests cover latest selection, grouped summaries, direct lookups, and retracted executions. The changelog records the new scope behaviour.
Preserve diagnostic filtering
packages/climate-ref/src/climate_ref/results/diagnostics.py, packages/climate-ref/tests/unit/results/test_results.py
Diagnostic value queries use ExecutionScope(include_retracted=False). Tests cover default exclusion, explicit inclusion, and latest selection involving retracted executions.

Priority: ⬇️ Low

Change: Feature

Merge Risk: ⚪ Minimal · up to d4ae4

No actionable issue remains; the change is mergeable after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 functions across 5 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarises the main change: sharing execution-scope handling between value and resource filters.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The pull request description is detailed and explains the scope, behaviour changes, defaults, exceptions, and compatibility impact. It does not use the required ## Description and ## Checklist heading…
Full details: Description check

Explanation

The pull request description is detailed and explains the scope, behaviour changes, defaults, exceptions, and compatibility impact. It does not use the required ## Description and ## Checklist headings, and it does not explicitly confirm each checklist item. The changed files show that tests and a changelog item were added.

Full details: Docstring Coverage

Explanation

Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 20 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lewisjared
lewisjared marked this pull request as ready for review October 21, 2026 01:58
@codecov

codecov Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.46154% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ages/climate-ref/src/climate_ref/results/_query.py 85.00% 1 Missing and 2 partials ⚠️
Flag Coverage Δ
core 94.22% <88.46%> (+<0.01%) ⬆️
providers 87.74% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...climate-ref/src/climate_ref/results/diagnostics.py 98.23% <100.00%> (+0.03%) ⬆️
.../climate-ref/src/climate_ref/results/executions.py 100.00% <ø> (ø)
...s/climate-ref/src/climate_ref/results/resources.py 98.16% <100.00%> (+0.36%) ⬆️
...ages/climate-ref/src/climate_ref/results/_query.py 84.11% <85.00%> (+0.45%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ilters

Adds ExecutionScope, holding include_retracted and latest_only, and apply_execution_scope.
MetricValueFilter, ResourceFilter and with_values now apply retraction and latest the same way.
ResourceFilter gains include_retracted, so summaries and measurements skip retracted executions by default.
profiles keeps every sample, retracted ones included.
@lewisjared lewisjared changed the title feat(results): add latest_only to ResourceFilter feat(results): share execution scope between value and resource filters Oct 21, 2026
Retracted executions are now excluded everywhere unless a caller opts in.
ResourcesReader.measurement still finds one by id, and profiles accepts a ResourceFilter.
Also tidies the filter docstrings, treats an empty slug as a constraint, and tests stats and promoted scoping.
@lewisjared
lewisjared merged commit c87a03b into main Oct 21, 2026
26 of 27 checks passed
@lewisjared
lewisjared deleted the feat/resources-latest-only branch October 21, 2026 03:51
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.

1 participant