Filter image files by run number in VENUS image cataloging - #110
Merged
darshdinger merged 2 commits intoJul 29, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #110 +/- ##
==========================================
+ Coverage 82.04% 82.33% +0.29%
==========================================
Files 16 16
Lines 1303 1325 +22
==========================================
+ Hits 1069 1091 +22
Misses 234 234 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
backmari
approved these changes
Jul 29, 2026
backmari
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me 👌 Good call to compare with real data.
I was going to suggest adding type hints, but I see that type hints are not use anywhere in this repo, so we can do that separately as a small maintenance story.
darshdinger
added a commit
that referenced
this pull request
Jul 29, 2026
Release including the run number filter for VENUS image cataloging (#110).
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.
Short description of the changes:
Catalog only the image files that belong to the run being cataloged, identified by the
Run_<run_number>token the VENUS DAQ writes into every image file name. This removes the redundant re-cataloging of earlier
runs' images that was making VENUS image cataloging slow enough to back up the shared autoreducers.
Long description of the changes:
The image file path PV is meant to name an image file, but for several detectors (QHY, Andor) it names the
directory holding a whole series of images, and consecutive runs of a series share that directory. The agent
cataloged every FITS/TIFF file in that directory, so each run re-cataloged every image written by the runs
before it. The cost grows with the length of the series, and since cataloging produces a thumbnail by reading
the full image, it ended up taking longer than writing the data out.
Checking ONCat for already-ingested files was considered and rejected: it becomes wasteful once a series
has hundreds of images, and it makes a job's behavior depend on the order and success of other jobs.
Per the agreement with the DAQ team, this filters by run number instead, which is a local, self-contained
rule.
Verified against production data before implementing, for each detector family:
The 881-file QHY directory is the pathological case from the report: 881 images spanning 881 distinct runs,
of which exactly one belongs to run 24828.
The run token is matched wherever it appears in the name, not only as a
YYYYMMDD_Run_<run>prefix.The convention quoted in the discussion holds for 114 of 120 recent runs sampled (2026-03 to 2026-06), but
TPX3 prepends a second, fixed date —
20250428_20260310_Run_15395_no_samp_ugg_test_...tiff— and some 2025TPX1 data leads with the run token instead (
Run_8787_20250516_...fits). Anchoring to the start of the namewould catalog zero images for those runs while still reporting COMPLETE. Checked end-to-end against 143
runs across every IPTS: the anchored form silently skips 19 of them, matching the token by position skips
none. This also matches the request in the discussion to filter on the run number appearing "somewhere in
the full tiff file path".
Two further findings from that check, both of which the filter now handles correctly:
.../Run_7352_DSet0,run 15291 ->
..._Run_15289_...). Those images are no longer cataloged under the wrong run; previously6000 and 2075 images respectively were.
cataloging work was redundant. For the QHY series specifically the reduction is 881 -> 1.
Specifics:
matches_run_number()implements the naming rule: aRun_<run_number>token that starts the name orfollows an underscore, and is followed by a non-digit. The trailing boundary matters — otherwise run 2482
would claim the images of runs 24820-24829, and that is not hypothetical: a substring match on
Run_2482hits 2 files in the QHY directory above, while the bounded match hits 0.
image_files()now takes the run number and filters every candidate through that rule._image_files_at()resolves a single location, which may be a file or a directory. Both are filteredthe same way, as agreed — a single file is not assumed to belong to the run naming it. This also fixes a
latent bug: a PV naming a file was previously dropped by an
os.path.isdir()guard, so those runscataloged no images at all.
previous run's; the previous run's images are now filtered out. Duplicate locations ingest once.
warns when a location yields nothing or does not exist.
Out of scope, noted while surveying the data:
.tiffiles exist under VENUS images (~1500 in the sampledIPTS directories) but only
.fitsand.tiffare globbed. That is pre-existing behavior, unchanged here.Check list for the pull request
Check list for the reviewer
Manual test for the reviewer
Unit tests:
Integration tests (requires Docker):
The VENUS integration fixture directory now holds a series shared by several runs, mirroring production:
test_oncat_catalog_venus_images— run 12345's PV names the directory. Only its 4 files are batched,including a TPX3-style name with a second date prefix; runs 12344, 12347 and 123450 (the prefix-collision
case) are skipped.
test_oncat_catalog_venus_single_image_path— run 12347's PV names a single file, which is batched alone.test_oncat_catalog_images_disabled— unchanged, confirms thecatalog_<INSTRUMENT>.pytoggle still gatesthe whole substep.
Against a running agent, the log lines to look for are
Skipping N image file(s) in <dir> belonging to other runsandCataloging N image file(s) for run <run>.References
EWM 17220