-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI to read first NWB file from each dandiset (#1695)
- Loading branch information
Showing
4 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Run DANDI read tests | ||
on: | ||
schedule: | ||
- cron: '0 6 * * *' # once per day at 1am ET | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run-tests: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
shell: bash -l {0} # necessary for conda | ||
steps: | ||
- name: Cancel non-latest runs | ||
uses: styfle/[email protected] | ||
with: | ||
all_but_latest: true | ||
access_token: ${{ github.token }} | ||
|
||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: 'recursive' | ||
fetch-depth: 0 # tags are required for versioneer to determine the version | ||
|
||
- name: Set up Conda | ||
uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
auto-update-conda: true | ||
activate-environment: ros3 | ||
environment-file: environment-ros3.yml | ||
python-version: "3.11" | ||
channels: conda-forge | ||
auto-activate-base: false | ||
|
||
- name: Install run dependencies | ||
run: | | ||
python -m pip install dandi pytest | ||
python -m pip uninstall -y pynwb # uninstall pynwb | ||
python -m pip install -e . | ||
python -m pip list | ||
- name: Conda reporting | ||
run: | | ||
conda info | ||
conda config --show-sources | ||
conda list --show-channel-urls | ||
- name: Run DANDI read tests | ||
run: | | ||
pytest -rP tests/read_dandi/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from dandi.dandiapi import DandiAPIClient | ||
import sys | ||
import traceback | ||
|
||
from pynwb import NWBHDF5IO | ||
from pynwb.testing import TestCase | ||
|
||
|
||
class TestReadNWBDandisets(TestCase): | ||
"""Test reading NWB files from the DANDI Archive using ROS3.""" | ||
|
||
def test_read_first_nwb_asset(self): | ||
"""Test reading the first NWB asset from each dandiset that uses NWB.""" | ||
client = DandiAPIClient() | ||
dandisets = client.get_dandisets() | ||
|
||
failed_reads = dict() | ||
for i, dandiset in enumerate(dandisets): | ||
dandiset_metadata = dandiset.get_raw_metadata() | ||
|
||
# skip any dandisets that do not use NWB | ||
if not any( | ||
data_standard["identifier"] == "RRID:SCR_015242" # this is the RRID for NWB | ||
for data_standard in dandiset_metadata["assetsSummary"].get("dataStandard", []) | ||
): | ||
continue | ||
|
||
dandiset_identifier = dandiset_metadata["identifier"] | ||
print("--------------") | ||
print(f"{i}: {dandiset_identifier}") | ||
|
||
# iterate through assets until we get an NWB file (it could be MP4) | ||
assets = dandiset.get_assets() | ||
first_asset = next(assets) | ||
while first_asset.path.split(".")[-1] != "nwb": | ||
first_asset = next(assets) | ||
if first_asset.path.split(".")[-1] != "nwb": | ||
print("No NWB files?!") | ||
continue | ||
|
||
s3_url = first_asset.get_content_url(follow_redirects=1, strip_query=True) | ||
|
||
try: | ||
with NWBHDF5IO(path=s3_url, load_namespaces=True, driver="ros3") as io: | ||
io.read() | ||
except Exception as e: | ||
print(traceback.format_exc()) | ||
failed_reads[dandiset] = e | ||
|
||
if failed_reads: | ||
print(failed_reads) | ||
sys.exit(1) |