Skip to content

DM-55183: Fix problem in NDF of overwriting components - #50

Merged
timj merged 28 commits into
mainfrom
tickets/DM-55183
Jun 11, 2026
Merged

DM-55183: Fix problem in NDF of overwriting components#50
timj merged 28 commits into
mainfrom
tickets/DM-55183

Conversation

@timj

@timj timj commented Jun 9, 2026

Copy link
Copy Markdown
Member

FITS was using EXTVERS,EXTNAME to allow HDUs with the same name to exist but NDF was overwriting. Rewrite to have FITS and NDF use the same tracking mechanism and then decide themselves what to do with the version value.

Also added a name shrinker to NDF writes to allow it to write cell coadds.

Checklist

  • ran Jenkins
  • added a release note for user-visible changes to doc/changes

@timj
timj force-pushed the tickets/DM-55183 branch from 77fedf6 to 4282ce9 Compare June 9, 2026 15:13
@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.13889% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.75%. Comparing base (93fb396) to head (109b51e).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
tests/test_cell_coadd.py 46.66% 8 Missing ⚠️
python/lsst/images/fits/_output_archive.py 60.00% 4 Missing ⚠️
python/lsst/images/ndf/_output_archive.py 93.93% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #50      +/-   ##
==========================================
+ Coverage   74.20%   74.75%   +0.54%     
==========================================
  Files         114      115       +1     
  Lines       13183    13436     +253     
==========================================
+ Hits         9783    10044     +261     
+ Misses       3400     3392       -8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@timj
timj force-pushed the tickets/DM-55183 branch from 4282ce9 to ea878ae Compare June 9, 2026 15:28
@timj timj mentioned this pull request Jun 9, 2026
2 tasks
@timj
timj force-pushed the tickets/DM-55183 branch from ea878ae to 6017a50 Compare June 9, 2026 23:12
timj and others added 20 commits June 9, 2026 16:19
When two callers add an array, table, or pointer with the same logical
name (e.g. each operand of a SumField calling add_array(name="data")
from the same nested archive) hierarchical backends silently overwrote
the first instance.  Add a shared _register_name helper on the
OutputArchive base class that returns (name, version) per logical name;
each backend renders version > 1 in its own way.

FITS already encoded a 1-based version as EXTVER; the helper replaces
the previous _hdus_by_name Counter and produces an identical layout.
NDF now appends _N to the leaf component before mapping to its HDF5
path so repeated names get sibling sub-NDFs.  Includes a regression
test that round-trips a SumField subtracted background through both
backends.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…-55183)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@timj
timj force-pushed the tickets/DM-55183 branch from 6017a50 to 1ecd5cd Compare June 9, 2026 23:19
Comment thread python/lsst/images/serialization/_output_archive.py
Comment thread python/lsst/images/serialization/_output_archive.py Outdated
Comment thread python/lsst/images/serialization/_output_archive.py Outdated
Comment thread python/lsst/images/ndf/_common.py Outdated
Comment thread python/lsst/images/ndf/_output_archive.py
timj and others added 3 commits June 10, 2026 16:03
Replace the lazy try/except initialization of _name_versions with an
unconditional __init__ on the OutputArchive base class; derived archive
classes now delegate to super().__init__().

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
_register_name now returns 0 for the first occurrence of a name; the
FITS backend adds one to produce the 1-based EXTVER and the NDF backend
renders later occurrences with a 1-based _{version + 1} suffix, so the
on-disk output is unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This reverts commit b680673cd0414ada36e74a9d27e6052dd446fcaf.

All the backends render the occurrence count 1-based on disk (the FITS
EXTVER keyword and the NDF _{version} suffix), so the 0-based return
value just forced every backend to add one back. Since the value is
a version rather than an index, 1-based is the more natural convention
after all. (DM-55183)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
timj and others added 4 commits June 11, 2026 07:38
Since shrunk-name collisions can only occur within a single file written
by a single process, a per-archive counter rendered as three uppercase
hex digits replaces the blake2b digest. The new HdsNameShrinker class
memoizes assignments so the same name always shrinks to the same result
within a file, leaves a longer readable prefix (11 characters instead of
6), and makes collisions impossible rather than improbable.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The two forms the normalization unified cannot collide: a direct
add_array(name="data") and a FITS pointer target's nested
add_array (which registers "/data") produce different EXTNAMEs
(DATA vs /DATA), so sharing a dedupe key only bumped EXTVER
spuriously. In the NDF backend names never reach _register_name with
a leading slash because serialize_pointer roots its nested archive at
the pointer's name.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Pin that repeated direct names get increasing EXTVERs and that a direct
name and a pointer target's leading-slash name produce distinct EXTNAMEs
with no spurious EXTVER bump.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@timj
timj force-pushed the tickets/DM-55183 branch from 8adf655 to 85112e5 Compare June 11, 2026 14:43
@timj
timj merged commit 09d1c08 into main Jun 11, 2026
17 checks passed
@timj
timj deleted the tickets/DM-55183 branch June 11, 2026 15:13
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