Skip to content

Add diagnostic attribute guards and CLI flag - #365

Merged
antond-weta merged 1 commit into
AcademySoftwareFoundation:mainfrom
antond-weta:diag_attributes
Oct 20, 2026
Merged

antond-weta merged 1 commit into
AcademySoftwareFoundation:mainfrom
antond-weta:diag_attributes

Conversation

@antond-weta

Copy link
Copy Markdown
Contributor

Add double-application guards to colour transform functions so they cannot be executed twice on the same image. Each function marks its output image buffer with an rta:* attribute on success, and returns false with an error message if the attribute is already present on the source:

  • apply_matrix -> rta:AppliedColourTransformMatrix
  • apply_scale -> rta:AppliedScale
  • apply_crop -> rta:AppliedCrop
  • apply_vignette_map -> rta:AppliedLensVignetteCorrection
  • apply_distortion_map -> rta:AppliedLensDistortionCorrection
  • apply_aberration_map -> rta:AppliedLensChromaticAberrationCorrection

Expand remove_diagnostic_attributes to remove all six attributes declared in attributes.h, and add a --keep-diagnostic-attributes CLI flag (linked to ImageConverter::Settings::keep_diagnostic_attributes) that controls whether these attributes are stripped from the output EXR in save_image().

Add Python binding for keep_diagnostic_attributes and regenerate the Python API docs.

Add unit tests verifying each guard fails on the second application: test_apply_matrix_twice, test_apply_crop_twice, test_apply_scale_twice, test_remove_diagnostic_attributes, test_apply_vignette_map_twice, test_apply_distortion_map_twice, test_apply_aberration_map_twice.

Also fix a pre-existing signature mismatch in prepare_transform_spectral (declaration had 5 params, definition had 6 with out_found_illuminant) and update all test call sites.

Assisted-by: nemotron-3.5-super-vl-free

Description

Tests

Checklist:

  • I have read the contribution guidelines.
  • I have read the Policy on AI Coding Assistants
    and if I used AI coding assistants, I have an Assisted-by: TOOL / MODEL
    line in the pull request description above.
  • I have updated the documentation, if applicable. (Check if there is no
    need to update the documentation, for example if this is a bug fix that
    doesn't change the API.)
  • I have ensured that the change is tested somewhere in the testsuite
    (adding new test cases if necessary).
  • My code follows the prevailing code style of this project. If I haven't
    already run clang-format before submitting, I definitely will look at the CI
    test that runs clang-format and fix anything that it highlights as being
    nonconforming.

@codecov-commenter

codecov-commenter commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.22642% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.04%. Comparing base (5d07dda) to head (4334804).

Files with missing lines Patch % Lines
src/cpp/rawtoaces_util/image_converter.cpp 95.50% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #365      +/-   ##
==========================================
+ Coverage   91.79%   92.04%   +0.24%     
==========================================
  Files          17       17              
  Lines        3876     3959      +83     
  Branches      582      591       +9     
==========================================
+ Hits         3558     3644      +86     
+ Misses        318      315       -3     
Files with missing lines Coverage Δ
src/cpp/include/rawtoaces/image_converter.h 100.00% <100.00%> (ø)
src/cpp/rawtoaces_util/lens_correction.cpp 99.35% <100.00%> (+0.03%) ⬆️
src/cpp/rawtoaces_util/image_converter.cpp 81.01% <95.50%> (+1.02%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5d07dda...4334804. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@soswow soswow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor things left:

Stale parameter comment prepare_transform_spectral still does not document out_found_illuminant.
Lens merge untested The lens tests call the map functions directly, so they never execute the extra_attribs merge.
No-op steps Default soft crop, an identity matrix, and a scale of 1 still write no attribute. That matches the existing skip in process_buffer.

up to you. LGTM

Add double-application guards to colour transform functions so they
cannot be executed twice on the same image. Each function marks its
output image buffer with an rta:* attribute on success, and returns
false with an error message if the attribute is already present on the
source:

- apply_matrix -> rta:AppliedColourTransformMatrix
- apply_scale -> rta:AppliedScale
- apply_crop -> rta:AppliedCrop
- apply_vignette_map -> rta:AppliedLensVignetteCorrection
- apply_distortion_map -> rta:AppliedLensDistortionCorrection
- apply_aberration_map -> rta:AppliedLensChromaticAberrationCorrection

Expand remove_diagnostic_attributes to remove all six attributes
declared in attributes.h, and add a --keep-diagnostic-attributes CLI
flag (linked to ImageConverter::Settings::keep_diagnostic_attributes)
that controls whether these attributes are stripped from the output
EXR in save_image().

Add Python binding for keep_diagnostic_attributes and regenerate the
Python API docs.

Add unit tests verifying each guard fails on the second application:
test_apply_matrix_twice, test_apply_crop_twice, test_apply_scale_twice,
test_remove_diagnostic_attributes, test_apply_vignette_map_twice,
test_apply_distortion_map_twice, test_apply_aberration_map_twice.

Also fix a pre-existing signature mismatch in prepare_transform_spectral
(declaration had 5 params, definition had 6 with out_found_illuminant)
and update all test call sites.

Assisted-by: nemotron-3.5-super-vl-free
Signed-off-by: Anton Dukhovnikov <antond@wetafx.co.nz>

Add unit test confirming diagnostic attributes removed in save_image

Add test_save_image_removes_diagnostic_attributes which verifies that
save_image strips all rta:* diagnostic attributes from the output ImageSpec
when keep_diagnostic_attributes is false (the default). The test saves an
ImageBuf with all diagnostic attributes set, reads the output EXR back, and
asserts none of the diagnostic attributes are present.

Assisted-by: nemotron-3.5-super-vl-free

Add unit test confirming diagnostic attributes kept in save_image when requested

Add test_save_image_keeps_diagnostic_attributes which verifies that
save_image preserves all rta:* diagnostic attributes in the output ImageSpec
when keep_diagnostic_attributes is set to true. The test saves an ImageBuf
with all diagnostic attributes set, reads the output EXR back, and asserts
all diagnostic attributes are preserved.

Complements test_save_image_removes_diagnostic_attributes which verifies
the default behavior (attributes stripped).

Assisted-by: nemotron-3.5-super-vl-free
@antond-weta
antond-weta merged commit cd5ef40 into AcademySoftwareFoundation:main Oct 20, 2026
29 checks passed
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.

3 participants