Skip to content

fix(reingest): rewrite embedded absolute paths when copying execution outputs#736

Merged
lewisjared merged 3 commits into
mainfrom
fix/reingest-rewrite-provenance-paths
Jun 18, 2026
Merged

fix(reingest): rewrite embedded absolute paths when copying execution outputs#736
lewisjared merged 3 commits into
mainfrom
fix/reingest-rewrite-provenance-paths

Conversation

@lewisjared

@lewisjared lewisjared commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Description

ref executions reingest failed for every ESMValTool diagnostic.

Reingest creates a new execution and copies the original execution's scratch tree to the new fragment with shutil.copytree, then re-runs build_execution_result against it. ESMValTool records absolute output paths in its diagnostic_provenance.yml files, and copytree duplicates those contents verbatim — so the copied provenance still pointed at the original execution's directory (.../<old_id>/executions/...). build_execution_result then tried to express those paths relative to the new output directory (.../<new_id>) and raised:

ValueError: '.../<old_id>/executions/.../jointplot.png' is not in the subpath of '.../<new_id>' OR one path is relative and the other is absolute.

The exception propagated to reingest's catch-all, which logged "Ingestion failed … Rolling back changes" and discarded the copy — so ESMValTool executions silently never reingested.

PMP/ILAMB were unaffected because they build their output lists by globbing the live output directory (always in-tree), whereas ESMValTool is the only provider that reads paths from a recorded artifact.

Fix

After copytree, rewrite the copied text artifacts to use the new scratch dir. Binary artefacts are never touched and unchanged files are left alone.

Checklist

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Changelog item added to changelog/

… outputs

ESMValTool records absolute output paths in its diagnostic_provenance.yml
files. Reingest copies an execution's scratch tree to a new fragment with
shutil.copytree, which duplicates those paths verbatim, so
build_execution_result tried to relativise them against the new output
directory and raised ValueError ("not in the subpath of"), silently rolling
back every ESMValTool reingest.

Re-point the embedded paths from the original scratch directory to the new
one after copying so the result can be rebuilt.
@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
core 93.31% <100.00%> (+<0.01%) ⬆️
providers 91.79% <ø> (ø)

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

Files with missing lines Coverage Δ
...s/climate-ref/src/climate_ref/executor/reingest.py 94.16% <100.00%> (+0.08%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Replace the bespoke _rewrite_copied_paths helper with the existing
climate_ref_core.output_files.rewrite_tree, which does the same content
rewrite with longest-match-first ordering and the shared SANITISED_FILE_GLOBS
set. Drops the now-redundant unit tests (rewrite_tree is covered in
test_output_files.py); the end-to-end reingest regression test is retained.
@lewisjared lewisjared merged commit cfde676 into main Jun 18, 2026
26 checks passed
@lewisjared lewisjared deleted the fix/reingest-rewrite-provenance-paths branch June 18, 2026 03:02
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