Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path expander II #679

Merged
merged 12 commits into from
Dec 19, 2023
Merged

Fix path expander II #679

merged 12 commits into from
Dec 19, 2023

Conversation

h-mayorquin
Copy link
Collaborator

@h-mayorquin h-mayorquin commented Dec 6, 2023

After #675 @bendichter mentioned that we are still missing the case of nested over matching:

"a_simple_pattern_{session_id}" applied to "tmp/base_directory/a_simple_pattern_2/nested/" will still return session_id="2/nested/" when it should not match

and proposed a solution of excluding metadata entries that have file separators (slashes in posix or double front slashes on windows) from the matches. This PR implements this solution and amends the tests to reflect that.

This should fix #674

@h-mayorquin h-mayorquin added the bug label Dec 6, 2023
@h-mayorquin h-mayorquin self-assigned this Dec 6, 2023
@h-mayorquin h-mayorquin marked this pull request as ready for review December 6, 2023 09:03
@bendichter
Copy link
Contributor

@h-mayorquin thanks for working on this. Let me see if it's possible with regex

@bendichter
Copy link
Contributor

oh, that's not easy with with parse library. hmm.

@bendichter
Copy link
Contributor

@h-mayorquin what do you think of this? I factored out the file creation logic so it can be used my multiple tests and I added a test case to ensure that the parser is not combining multiple nested directories into a single metadata field

Copy link
Collaborator Author

@h-mayorquin h-mayorquin left a comment

Choose a reason for hiding this comment

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

@bendichter This is OK to me. The code duplication across the two tests did bother me and I was thinking to use a module scoped pytest fixture to get rid of it. I was on the edge though because of the trade-off between your test being very explicit which is good and some code duplication which is bad.

But if you think this makes more sense and I was already on the edge it seems tha the average favors a bit of abstraction.

If you are Ok with this we should mege!

Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Merging #679 (46f3429) into main (dcb1f85) will increase coverage by 0.00%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #679   +/-   ##
=======================================
  Coverage   92.06%   92.06%           
=======================================
  Files         115      115           
  Lines        5960     5963    +3     
=======================================
+ Hits         5487     5490    +3     
  Misses        473      473           
Flag Coverage Δ
unittests 92.06% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/neuroconv/tools/path_expansion.py 96.15% <100.00%> (+0.23%) ⬆️

@h-mayorquin h-mayorquin merged commit acd9fb3 into main Dec 19, 2023
36 checks passed
@h-mayorquin h-mayorquin deleted the fix_path_expander_II branch December 19, 2023 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LocalPathExpander should match only folder_paths or file_paths depending on the spec.
3 participants