Repository navigation
feat: results-library phase 0b — honest reads - #1737
Merged
Merged
Conversation
- Aggregator.from_directory(..., on_error="skip"|"raise"): an unreadable zip (BadZipFile, or EOFError / zlib.error from a damaged member) is skipped, logged and recorded in agg.errors as (path, exception) instead of failing the whole scan; a partial extraction is removed. unzip_directory gains the same on_error and returns its errors; add_directory, filter and slicing carry errors along. - An empty aggregator logs a warning naming the directory and filters; every print in the aggregator is now logging. - AggregateCSV: strict=True by default; header is the union of every row's columns; rows are built before the file is opened and written via open_atomic, so a failed or interrupted save leaves the previous CSV whole; save() reports (logs and returns) columns blank in every row; add_label_column joins a dict of labels by key (search id, or key=callable), and under strict a positional list must match the aggregator's length. - Row regression test on an asymmetric latent PDF (median, max_lh, 1-sigma and 3-sigma bounds all distinct). - post_fit_output docstring states the zip is always written and the folder is removed only under remove_files; the "Removing all files" log is conditional. Refs #1734 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Results-library phase 0, PR 0b of 2 (#1734), stacked on PR 0a. Makes the aggregator and
AggregateCSVreport problems instead of hiding them:Aggregator.from_directoryscan; it is collected inagg.errors(or raised withon_error="raise")AggregateCSVis strict by default (unknown columns raise), the header is the union of all rows, saves are atomic, labels can be joined by key, andsave()reports columns that are blank for every rowRowsigma-1 / sigma-3 / max_lh on an asymmetric latent PDF; the invertedpost_fit_outputdocstring is fixedMerge order: after PR 0a (this PR's base is the 0a branch; GitHub retargets it to
mainwhen 0a merges).API Changes
AggregateCSVnow defaults tostrict=True, andfrom_directorynow defaults toon_error="skip". Both are behaviour changes; see Migration. New:agg.errors,on_error=,add_label_column(..., key=), andsave()returns the blank columns. Aggregator messages move from stdout tologging.See full details below.
Downstream to check: the
euclid_strong_lens_modeling_pipelinecatalogue scripts (catalogue/scripts/{lens_mass,lens_sersic,source_sersic,magnitudes,astrometric_offsets}.py,workflow/csv_make.py) callaf.AggregateCSV(aggregator=...)withoutstrict=and pass positional label lists. If a variable path is missing for some fits, or a label list's length differs from the aggregator, they will now raise instead of writing blanks. Confirmed: one euclid pipeline test fails on this branch for exactly that reason. Passingstrict=Falseexplicitly in those scripts works with both the released and this PyAutoFit, so that euclid change can merge first. Resolved: PyAutoLabs/euclid_strong_lens_modeling_pipeline#112 (explicitstrict=False, merged first; euclid tests 352/352 against this branch).Test Plan
test_autofit/aggregator/summary_files/test_honest_reads.py(new, 17 tests): one corrupt zip →len(agg.errors) == 1(with and withoutunzip_temporary),on_error="raise"raises; a damaged member is collected; empty aggregator warns; nothing printed to stdout; unknown column raises and writes no file; union header; a save interrupted mid-write leaves the old CSV byte-identical; blank columns reported; label joins by key and by search id; asymmetric-latentRowsigma-1/sigma-3/max_lhtest_autofitsuite: 3,969 passed, 2 skipped, 1 xfailedpyauto-heart smoke autofit autolens_test euclid: 56 passed, 0 failedeuclid_strong_lens_modeling_pipelinetests/: 351 passed, 1 failed —test_catalogue_missing_assets.py::test_bundle_reaches_later_stages_with_missing_assets:source_sersicasks forgalaxies.source.bulge.centre.centre_0on fits without it, which now raisesKeyErrorunder the strict default (see Downstream to check)Full API Changes (for automation & release notes)
Added
Aggregator.from_directory(..., on_error="skip" | "raise")andAggregator.errors— list of(path, exception); carried throughadd_directory,filterand slicingunzip_directory(directory, on_error="raise")returns its error listAggregateCSV.add_label_column(name, values: list | dict, key=None)— a dict is joined bykey(search_output), defaulting to the search idAggregateCSV.save()returns the columns blank in every row and logs them as a warningChanged behaviour
AggregateCSV(strict=True)is the default: an unknown variable column raisesKeyError; a dict label with no value for a search raisesKeyError; a positional label list of the wrong length raisesValueErrorfrom_directorydefaults toon_error="skip"; previously a corrupt zip always raisedBadZipFile. Under"raise",BadZipFile/EOFError/zlib.errorare raised asBadZipFilenaming the original errorsave()writes atomicallyprints →logging(empty result, incomplete-excluded counts and skipped zips are warnings)remove_filesis setMigration
af.AggregateCSV(aggregator, strict=False)Aggregator.from_directory(path, on_error="raise")logginginsteadRefs #1734
🤖 Generated with Claude Code