Skip to content

Commit

Permalink
Merge pull request #1108 from catalystneuro/force_usage_of_latest_nwb…
Browse files Browse the repository at this point in the history
…_inspector_release

Check for usage of latest NWB Inspector release
  • Loading branch information
yarikoptic committed Sep 3, 2022
2 parents e74c5ac + 2274902 commit 17e0b04
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ jobs:
python -m pip install --upgrade pip wheel
pip install ".[test]"
- name: Install dev version of pynwb
- name: Install dev version of pynwb and nwbinspector
if: matrix.mode == 'dev-deps'
run: |
pip install git+https://github.com/NeurodataWithoutBorders/nwbinspector
pip install git+https://github.com/NeurodataWithoutBorders/pynwb
- name: Run all tests
Expand Down
30 changes: 30 additions & 0 deletions dandi/files/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
from dandischema.models import BareAsset, CommonModel
from dandischema.models import Dandiset as DandisetMeta
from dandischema.models import get_schema_version
from etelemetry import get_project
from nwbinspector import Importance, inspect_nwb, load_config
from nwbinspector.utils import get_package_version
from packaging.version import Version
from pydantic import ValidationError
import requests

Expand Down Expand Up @@ -469,6 +472,33 @@ def get_validation_errors(
else:
# make sure that we have some basic metadata fields we require
try:
# Ensure latest version of NWB Inspector is installed and used client-side
try:
max_version = Version(
get_project(repo="NeurodataWithoutBorders/nwbinspector")[
"version"
]
)
current_version = get_package_version(name="nwbinspector")

if current_version < max_version:
errors.append(
f"NWB Inspector version {current_version} is installed - please "
f"use the latest release of the NWB Inspector ({max_version}) "
"when performing `dandi validate`. To update, run "
"`pip install -U nwbinspector` if you installed it with `pip`."
)
return errors

except Exception as e: # In case of no internet connection or other error
lgr.warning(
"Failed to retrieve NWB Inspector version due to %s: %s",
type(e).__name__,
str(e),
)

# Run NWB Inspector with 'dandi' config
# CRITICAL errors and above are equivalent to validation errors
errors.extend(
[
error.message
Expand Down
10 changes: 5 additions & 5 deletions dandi/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def simple2_nwb(
subject=pynwb.file.Subject(
subject_id="mouse001",
date_of_birth=datetime(2016, 12, 1, tzinfo=tzutc()),
sex="M",
species="mouse",
sex="U",
species="Mus musculus",
),
**simple1_nwb_metadata,
)
Expand All @@ -128,9 +128,9 @@ def simple3_nwb(
return make_nwb_file(
str(tmpdir_factory.mktemp("simple2").join("simple2.nwb")),
subject=pynwb.file.Subject(
date_of_birth=datetime(2016, 12, 1, tzinfo=tzutc()),
sex="M",
species="mouse",
age="P1D/",
sex="O",
species="Mus musculus",
),
**simple1_nwb_metadata,
)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ install_requires =
pycryptodomex # for EncryptedKeyring backend in keyrings.alt
pydantic >= 1.9.0
pynwb >= 1.0.3,!=1.1.0
nwbinspector >= 0.3.8
nwbinspector >= 0.4.12
pyout >=0.5, !=0.6.0
python-dateutil
requests ~= 2.20
Expand Down

0 comments on commit 17e0b04

Please sign in to comment.