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

Special handling of bytes_repr for mock filesets #743

Merged
merged 2 commits into from
May 30, 2024
Merged

Conversation

tclose
Copy link
Contributor

@tclose tclose commented Mar 26, 2024

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Summary

Implements special bytes_repr function for mocked filesets in(i.e. produced by Nifti1.mock("/path/to/mock")) as the fileset one yields the file mtimes in the cache key, which obviously don't exist for mocked files.

Checklist

  • I have added tests to cover my changes (if necessary)
  • I have updated documentation (if necessary)

Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 69.23077% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 84.23%. Comparing base (7d84fba) to head (bdf6abf).
Report is 2 commits behind head on master.

Current head bdf6abf differs from pull request most recent head dd6fa8a

Please upload reports for the commit dd6fa8a to get more accurate results.

Files Patch % Lines
pydra/utils/hash.py 69.23% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #743       +/-   ##
===========================================
+ Coverage   15.14%   84.23%   +69.09%     
===========================================
  Files          53       26       -27     
  Lines       15693     5137    -10556     
  Branches     2788     1450     -1338     
===========================================
+ Hits         2376     4327     +1951     
+ Misses      12988      804    -12184     
+ Partials      329        6      -323     
Flag Coverage Δ
unittests 84.23% <69.23%> (+69.12%) ⬆️

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

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

Comment on lines +489 to +497
# Need to disable the mtime cache key for mocked filesets. Used in doctests
@register_serializer(MockMixin)
def bytes_repr_mock_fileset(
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like putting test code in main modules. What about adding pydra.testing.fixtures and including:

@pytest.fixture(scope='session')
def register_mock_mixin_serializer():
    @register_serializer(MockMixin)
    ...

Then in conftest.py:

from pydra.testing.fixtures import register_mock_mixin_serializer

This would allow downstream tools that need this feature to also put this import in their conftest.py.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with the sentiment in general, but in this case I reckon that might be creating a gotcha that would take a bit of tracking down how to solve for little practical benefit, i.e if someone creates a new task package and wants to write a doctest using NiftiGz.mock(), then they would need to know that they also have to add this fixture

@tclose tclose added enhancement New feature or request minor Increment the minor version when merged (label from auto) labels May 28, 2024
@effigies effigies merged commit ce10332 into master May 30, 2024
41 checks passed
@tclose tclose deleted the mock-bytes-repr branch June 3, 2024 22:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor Increment the minor version when merged (label from auto)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants