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

Upgrade validation methods - make pynwb.validate behave similarly for io and paths #1911

Draft
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

stephprince
Copy link
Contributor

Motivation

Address #1807 (related to other validation upgrades described in #1808). This is a breaking change for the next major release.

The expected behavior is for validate to return the same output whether paths or io is provided. This was previously discussed here, where the 'correct' behavior for the example below is to return: "The namespace 'core' is included by the namespace 'ndx-testextension'. Please validate against that namespace instead".

How to test the behavior?

import h5py
from pynwb.validate import validate
from pynwb import NWBHDF5IO

path = 'tests/back_compat/2.1.0_nwbfile_with_extension.nwb'
io = NWBHDF5IO('tests/back_compat/2.1.0_nwbfile_with_extension.nwb')

print('Validating all with paths')
validate(paths=[path], namespace="core", verbose=True)

print('Validating core with io')
validate(io=io, namespace="core", verbose=True)

Checklist

  • Did you update CHANGELOG.md with your changes?
  • Have you checked our Contributing document?
  • Have you ensured the PR clearly describes the problem and the solution?
  • Is your contribution compliant with our coding style? This can be checked running flake8 from the source directory.
  • Have you checked to ensure that there aren't other open Pull Requests for the same change?
  • Have you included the relevant issue number using "Fix #XXX" notation where XXX is the issue number? By including "Fix #XXX" you allow GitHub to close issue #XXX when the PR is merged.

)

if io is not None:
namespace_dependencies = io.load_namespaces(namespace_catalog=catalog,
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 wasn't sure if there is a better way to load the namespaces from the io object, I realize this is HDF5 specific, but it looks like the original namespace loading was as well? I was wondering how this works for Zarr validation?

self.assertEqual(fake_out.getvalue(), "")

def test_validate_io_and_path_same(self):
"""Test that validating a file with an io object and a path return the same results."""
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'm not sure if all of these are necessary to include, but wanted to double check they were all equivalent

Copy link

codecov bot commented May 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.00%. Comparing base (04a6506) to head (76a4f0f).

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1911      +/-   ##
==========================================
+ Coverage   91.88%   92.00%   +0.11%     
==========================================
  Files          27       27              
  Lines        2651     2663      +12     
  Branches      692      694       +2     
==========================================
+ Hits         2436     2450      +14     
+ Misses        142      141       -1     
+ Partials       73       72       -1     
Flag Coverage Δ
integration 73.07% <100.00%> (+0.27%) ⬆️
unit 83.92% <44.89%> (-0.05%) ⬇️

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.


if status == 1:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

from what I could tell, this status check was never reset to 0, so if any of the paths return a nonzero status, _validate_helper would not be run on any subsequent paths. Is that the intended behavior? Or maybe I am misunderstanding something.

@rly rly added this to the 3.0 milestone Oct 10, 2024
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.

2 participants