Skip to content

Ensure all IntendedFor matching params must match#860

Open
mslw wants to merge 2 commits into
nipy:masterfrom
mslw:intended-for-params-all
Open

Ensure all IntendedFor matching params must match#860
mslw wants to merge 2 commits into
nipy:masterfrom
mslw:intended-for-params-all

Conversation

@mslw

@mslw mslw commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

The list of matching_parameters specified in POPULATE_INTENDED_FOR_OPTS can have multiple values. If I'm not mistaken, the code would test all of them, but then act only on the result of the last test, which seems unintended.

This assumes that matching_parameters are to be interpreted as all(), and makes the check behave accordingly.

It seems that the matching functions have so far only been tested with a single parameter. This PR adds a test for find_compatible_fmaps_for_run_union being called with two parameters, and a set of files for which there is one pairing which matches both, but more which match just one. The assumption for the test is that the desired operation is all(), which seems the more logical alternative to me.

Fixes #859

@codecov

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.44%. Comparing base (7e9e9a6) to head (2746e29).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #860      +/-   ##
==========================================
+ Coverage   83.38%   83.44%   +0.05%     
==========================================
  Files          42       42              
  Lines        4436     4451      +15     
==========================================
+ Hits         3699     3714      +15     
  Misses        737      737              

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

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

@mslw mslw force-pushed the intended-for-params-all branch 2 times, most recently from 28d05f9 to b01c54e Compare June 15, 2026 22:58
mslw added 2 commits June 16, 2026 12:13
Although `matching_parameters` in `POPULATE_INTENDED_FOR_OPTS` can be
a list with multiple values, it seems that the matching functions
have so far only been tested with a single parameter.

This adds a test for `find_compatible_fmaps_for_run` being called with
two parameters ("ShimSetting" and "CustomAcquisitionLabel"). We test a
situation with three func files and two fmap files, in which only one
fmap-func pairing meets both criteria (and more meet only one). We
assume that all `matching_parameters` must match.

Because the test is concerned with logic of
`find_compatible_fmaps_for_run`, getting relevant information from a
JSON file is mocked (to return preset values) to avoid having to set
up a dataset structure on the filesystem; this should makes the test
simpler and more explicit.
The list of matching_parameters specified in
`POPULATE_INTENDED_FOR_OPTS` can have multiple values. The code would
loop over them and check if a given field map and run are compatible -
but the innermost loop ended with a conditional `continue` statement.
Being at the end of the loop, `continue` had no effect. As a result,
only the value from the last iteration made it to the conditional in the
outer loop, where the field map was taken (or not).

In other words, only the last parameter influenced the decision (so the
operation was neither "all", nor "any").

This commit replaces `continue` with `break`, which does what the inline
comment after `continue`, "don't bother checking more params" suggested.

Consequently, this makes "POPULATE_INTENDED_FOR_OPTS" behave as a
logical union (all).
@mslw mslw force-pushed the intended-for-params-all branch from b01c54e to 2746e29 Compare June 16, 2026 10:13
@yarikoptic yarikoptic requested a review from pvelasco June 19, 2026 13:39
@yarikoptic

Copy link
Copy Markdown
Member

Sounds/looks logical but not sure how we missed that in the original implementation or through the use. @pvelasco please have a look

@mslw

mslw commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

I'm likely not adding much here, but I admit that seeing that the code in question was long unchanged gave me pause, but in the end didn't change my conclusion.

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.

With multiple IntendedFor matching parameters, only the last one matters

2 participants