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

filter out warnings when validating against namespaces in tests #1961

Merged
merged 6 commits into from
Sep 9, 2024

Conversation

stephprince
Copy link
Contributor

@stephprince stephprince commented Sep 6, 2024

Motivation

When running the tests in test.py, the validation module was trying to validate against several invalid namespaces.

2024-09-05 18:22:05,083 - INFO - Namespace found: <frozen
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: runpy>:128:
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: RuntimeWarning:
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: 'pynwb.validate'
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: found
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: in
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: sys.modules
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: after
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: import
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: of
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: package
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: 'pynwb',
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: but
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: prior
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: to
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: execution
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: of
======================================================================
2024-09-05 18:22:05,083 - INFO - Namespace found: 'pynwb.validate';

The namespaces are retrieved from the stdout of python -m pynwb.validate --list-namespaces, which could still be error prone. Another option would be to replace the get_namespaces function in test.py entirely with:

 from pynwb.validate import _get_cached_namespaces_to_validate
 namespaces, _, _ = _get_cached_namespaces_to_validate(nwb)

How to test the behavior?

python test.py -v -w

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 ruff check . && codespell 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.

@stephprince stephprince marked this pull request as ready for review September 6, 2024 16:43
@stephprince stephprince requested a review from rly September 6, 2024 16:43
Copy link

codecov bot commented Sep 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.20%. Comparing base (1178e0d) to head (f28fedb).
Report is 21 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #1961   +/-   ##
=======================================
  Coverage   92.20%   92.20%           
=======================================
  Files          27       27           
  Lines        2656     2656           
  Branches      693      693           
=======================================
  Hits         2449     2449           
  Misses        134      134           
  Partials       73       73           
Flag Coverage Δ
integration 73.19% <100.00%> (ø)
unit 83.77% <66.66%> (ø)

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.

@stephprince stephprince mentioned this pull request Sep 7, 2024
11 tasks
@rly
Copy link
Contributor

rly commented Sep 7, 2024

I prefer the alternate option. Filtering out all warnings feels kind of hacky. We should just get the cached namespaces through another means, as you suggested. I would change _get_cached_namespaces_to_validate to be public though (remove the leading underscore).

@stephprince stephprince merged commit 6196568 into dev Sep 9, 2024
25 checks passed
@stephprince stephprince deleted the fix/validation-stdout-in-tests branch September 9, 2024 17:25
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