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

Generalize Validation #1511

Merged
merged 48 commits into from
Oct 19, 2022
Merged

Generalize Validation #1511

merged 48 commits into from
Oct 19, 2022

Conversation

CodyCBakerPhD
Copy link
Collaborator

@CodyCBakerPhD CodyCBakerPhD commented Jul 18, 2022

fix #1431
replaces #1494 by branching from dev instead of the modularity improvement

Motivation

WIP synchronizing the behavior of the CLI pynwb.validate function with the library-imported one, namely for the purposes of validating against cached namespaces (but also just to have identical behavior between library and CLI use cases).

How to test the behavior?

Need to...

  • Thoroughly test that the CLI usage behaves as it used to
  • The cached namespace feature is indeed available to the new library method as well
  • Ensure there is no break in back-combability when using the previous methods

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? - a splinter/extension of enh/getcachednamespaces
  • 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.

@CodyCBakerPhD CodyCBakerPhD added the topic: validator issues related to validation of files label Jul 18, 2022
@CodyCBakerPhD CodyCBakerPhD self-assigned this Jul 18, 2022
@CodyCBakerPhD CodyCBakerPhD changed the title branch from dev Generalize Validation Jul 18, 2022
@CodyCBakerPhD CodyCBakerPhD mentioned this pull request Jul 18, 2022
6 tasks
src/pynwb/validation.py Outdated Show resolved Hide resolved
@rly
Copy link
Contributor

rly commented Aug 11, 2022

Ah, looks like you are still working on this. Happy to help or review it when ready.

@CodyCBakerPhD
Copy link
Collaborator Author

CodyCBakerPhD commented Sep 1, 2022

@rly @oruebel This is ready to be looked at...

Main issue I'm having right now is getting the non-required argument parsing through docval to work.

Traceback (most recent call last):
  File "C:\Users\Raven\.conda\envs\pynwb\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Raven\.conda\envs\pynwb\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "d:\github\pynwb\src\pynwb\validate.py", line 223, in <module>
    validate_cli()
  File "d:\github\pynwb\src\pynwb\validate.py", line 213, in validate_cli
    validation_errors, validation_status = validate(
  File "C:\Users\Raven\.conda\envs\pynwb\lib\site-packages\hdmf\utils.py", line 648, in func_call
    pargs = _check_args(args, kwargs)
  File "C:\Users\Raven\.conda\envs\pynwb\lib\site-packages\hdmf\utils.py", line 637, in _check_args
    raise ExceptionType(msg)
TypeError: validate: incorrect type for 'namespace' (got 'NoneType', expected 'str or NoneType')

src/pynwb/validate.py Outdated Show resolved Hide resolved
@CodyCBakerPhD
Copy link
Collaborator Author

but likewise if I remove the type: (..., type(None)) to mimic the pattern of https://github.com/NeurodataWithoutBorders/pynwb/blob/dev/src/pynwb/image.py#L38-L43 I still get

Traceback (most recent call last):
  File "C:\Users\Raven\.conda\envs\pynwb\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Raven\.conda\envs\pynwb\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "d:\github\pynwb\src\pynwb\validate.py", line 223, in <module>
    validate_cli()
  File "d:\github\pynwb\src\pynwb\validate.py", line 213, in validate_cli
    validation_errors, validation_status = validate(
  File "C:\Users\Raven\.conda\envs\pynwb\lib\site-packages\hdmf\utils.py", line 648, in func_call
    pargs = _check_args(args, kwargs)
  File "C:\Users\Raven\.conda\envs\pynwb\lib\site-packages\hdmf\utils.py", line 637, in _check_args
    raise ExceptionType(msg)
TypeError: validate: incorrect type for 'namespace' (got 'NoneType', expected 'str')

@CodyCBakerPhD
Copy link
Collaborator Author

Main issue I'm having right now is getting the non-required argument parsing through docval to work.

Never mind, I just had to set the CLI parser default value to resolve this.

@CodyCBakerPhD CodyCBakerPhD marked this pull request as ready for review September 2, 2022 17:03
@CodyCBakerPhD
Copy link
Collaborator Author

@rly @oruebel Now I'm trying to debug these failing validation CLI tests, but when I locally run the tests it gives

   .... Massive stack trace....
               FileNotFoundError: [Errno 2] No such file or directory: 'coverage'

How do I obtain this 'coverage' folder with what I presume contains NWB files I need to test against?

@rly rly mentioned this pull request Sep 27, 2022
3 tasks
@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Merging #1511 (06ca152) into dev (6e1f131) will increase coverage by 0.68%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev    #1511      +/-   ##
==========================================
+ Coverage   90.65%   91.34%   +0.68%     
==========================================
  Files          25       25              
  Lines        2494     2507      +13     
  Branches      466      471       +5     
==========================================
+ Hits         2261     2290      +29     
+ Misses        148      137      -11     
+ Partials       85       80       -5     
Flag Coverage Δ
integration 70.56% <100.00%> (+0.95%) ⬆️
unit 84.44% <24.71%> (+0.28%) ⬆️

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

Impacted Files Coverage Δ
src/pynwb/__init__.py 76.15% <100.00%> (-1.22%) ⬇️
src/pynwb/validate.py 100.00% <100.00%> (+21.05%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@rly
Copy link
Contributor

rly commented Oct 19, 2022

Coverage on the new validate.py is now 100%. Woot!

rly
rly previously approved these changes Oct 19, 2022
@oruebel
Copy link
Contributor

oruebel commented Oct 19, 2022

Thanks @CodyCBakerPhD and @rly for all the work on this PR to clean up validation!

@rly rly merged commit d4dd8e2 into dev Oct 19, 2022
@rly rly deleted the generalize_validate_from_dev branch October 19, 2022 00:46
@CodyCBakerPhD CodyCBakerPhD mentioned this pull request Nov 1, 2022
6 tasks
@stephprince stephprince mentioned this pull request May 29, 2024
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: validator issues related to validation of files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support validation against cached namespace via flag on pynwb.validate
3 participants