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

Test ROS3 streaming in CI and add ROS3 tutorial #1393

Merged
merged 38 commits into from
Aug 13, 2021
Merged

Test ROS3 streaming in CI and add ROS3 tutorial #1393

merged 38 commits into from
Aug 13, 2021

Conversation

rly
Copy link
Contributor

@rly rly commented Aug 11, 2021

Motivation

Resolve #1392.

How to test the behavior?

python test.py -r

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.

@codecov
Copy link

codecov bot commented Aug 11, 2021

Codecov Report

Merging #1393 (772236b) into dev (c0ad3e7) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #1393   +/-   ##
=======================================
  Coverage   76.78%   76.78%           
=======================================
  Files          37       37           
  Lines        2731     2731           
  Branches      455      455           
=======================================
  Hits         2097     2097           
  Misses        552      552           
  Partials       82       82           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3760038...772236b. Read the comment docs.

@rly rly marked this pull request as ready for review August 11, 2021 22:14
@rly rly requested review from oruebel and bendichter August 11, 2021 22:14
@rly
Copy link
Contributor Author

rly commented Aug 11, 2021

I added a ROS3 streaming test to the CI. The test pulls a small file from DANDI. Please review the test to make sure it makes sense. I hope this doesn't put too much of a burden on DANDI.

The CI runs on CircleCI (linux) on every push and nightly, and it runs on Azure (Windows, MacOS) nightly.

Comment on lines 46 to 47
filepath = 'sub-anm372795/sub-anm372795_ses-20170718.nwb'
s3_path = get_dandi_s3_url(dandiset_id, filepath)
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than using an actual user asset, I think it would make sense for DANDI to have an S3 bucket with small test files. This is both to make this easier to control but also because running tests against actual data will throw off usage stats for DANDI.

Copy link
Contributor

Choose a reason for hiding this comment

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

Having an S3 test bucket on DANDI would also allow testing against NWB files with different versions (as part of a nightly test).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test now points to https://dandiarchive.s3.amazonaws.com/ros3test.nwb assuming that @yarikoptic or someone else on the DANDI team can host that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assuming this is an easy thing for the DANDI team to do, I'd like to hold the release until tomorrow so that we can get this PR in. @oruebel would that be all right?

Copy link
Contributor

Choose a reason for hiding this comment

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

which file we should host? I would prefer if you provide one so it is not encumbered by any possible fiasco with user wishes/license/suboptimal nwb version etc. Just create one (or some) you would like to see representative of the features you would gain with ROS3 (not fetching "large" data arrays etc) and share and we will gladly host it/them

Copy link

Choose a reason for hiding this comment

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

@rly - nothing is stable till you publish. but once published then you should expect some stability.

regarding redirect, i'm 90% sure the hdf5 library doesn't support a redirect.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point. Now that we have published datasets, maybe we should use one of those.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After a dataset is published, can I still add files to it, or is it locked forever?

Copy link

Choose a reason for hiding this comment

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

you can think of it as software releases. you can add, but the published version contains only the assets it was published with.

@rly
Copy link
Contributor Author

rly commented Aug 11, 2021

@oruebel I added a short tutorial on how to do streaming. Feel free to add to it.

Fix #1367.

@oruebel
Copy link
Contributor

oruebel commented Aug 12, 2021

I added a short tutorial on how to do streaming. Feel free to add to it.

Thanks! Looks good. I created a thumbnail for the tutorial.

Comment on lines +46 to +47
# with NWBHDF5IO(s3_path, mode='r', load_namespaces=True, driver='ros3') as io:
# nwbfile = io.read()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason for using a context-manager here on read. I'm just wondering since we normally tend to use contexts only on write.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is a good question. I had always followed the rule of thumb to use a context manager when opening a file to be safe. It should not make a difference in virtually all cases - the file will be closed on garbage collection and having the file open doesn't stop other processes from reading or modifying the file. However, if someone is using Windows and going to delete the file before garbage collection (or thinks another process might delete it), then the file must be explicitly closed before it can be deleted. So I think to be safe, it is ever so slightly better to use a context manager.

import h5py
import os

filename = 'nwbfile.nwb'
f = h5py.File(filename, 'r')
os.remove(filename)  # fails on windows

See also:
https://stackoverflow.com/questions/56149237/do-i-need-to-manually-close-a-hdf5-file
https://stackoverflow.com/questions/7395542/is-explicitly-closing-files-important/7395906#7395906

* rmv s3 utils
* rmv corresponding tests
* update tutorial to use latest dandi tools instead
@bendichter
Copy link
Contributor

@rly you used functions that I wrote a while back before these features were exposed in the dandi python package. Now that those tools are available, it is much simpler to use them. I pushed the change. What do you think?

@rly
Copy link
Contributor Author

rly commented Aug 12, 2021

@bendichter This looks good, thanks!

bendichter
bendichter previously approved these changes Aug 12, 2021
oruebel
oruebel previously approved these changes Aug 12, 2021
Copy link
Contributor

@oruebel oruebel left a comment

Choose a reason for hiding this comment

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

Looks good. Just for record-keeping, can we add a note in the release notes that there is now a DANDI asset for nightly tests with a link. Not that this is technically a feature of PyNWB but it would be nice to have a record of it.

@rly
Copy link
Contributor Author

rly commented Aug 13, 2021

Looks good. Just for record-keeping, can we add a note in the release notes that there is now a DANDI asset for nightly tests with a link. Not that this is technically a feature of PyNWB but it would be nice to have a record of it.

Updated now

@rly rly merged commit 7651e9d into dev Aug 13, 2021
@rly rly deleted the ci/ros3 branch August 13, 2021 03:24
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.

Add tests for ROS3 streaming support
5 participants