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

[Bug]: nwbinspector CLI fails when url is provided #558

Open
3 tasks done
stephprince opened this issue Jan 29, 2025 · 1 comment · May be fixed by #559
Open
3 tasks done

[Bug]: nwbinspector CLI fails when url is provided #558

stephprince opened this issue Jan 29, 2025 · 1 comment · May be fixed by #559
Assignees
Labels
category: bug errors in the code or code behavior

Comments

@stephprince
Copy link
Contributor

What happened?

When running NWBInspector from the command line, providing a URL fails because the inspector attempts to inspect it as a dandi file path

nwbinspector "https://dandiarchive.s3.amazonaws.com/blobs/3d7/39a/3d739ac0-10fb-41ef-80be-f1479cec44c0"

Traceback:

A newer version (0.66.4) of dandi/dandi-cli is available. You are using 0.64.0
Error 404 while sending GET request to https://api.dandiarchive.org/api/dandisets/https/: 
<!doctype html>
<html lang="en">
<head>
  <title>Not Found</title>
</head>
<body>
  <h1>Not Found</h1><p>The requested resource was not found on this server.</p>
</body>
</html>

Traceback (most recent call last):
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 822, in _get_data
    self.client.get(f"/dandisets/{self.identifier}/")
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 303, in get
    return self.request("GET", path, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 277, in request
    raise HTTP404Error(msg, response=result)
dandi.exceptions.HTTP404Error: Error 404 while sending GET request to https://api.dandiarchive.org/api/dandisets/https/: 
<!doctype html>
<html lang="en">
<head>
  <title>Not Found</title>
</head>
<body>
  <h1>Not Found</h1><p>The requested resource was not found on this server.</p>
</body>
</html>


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/smprince/anaconda3/envs/nwbinspector/bin/nwbinspector", line 8, in <module>
    sys.exit(_nwbinspector_cli())
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smprince/Documents/code/nwbinspector/src/nwbinspector/_nwbinspector_cli.py", line 201, in _nwbinspector_cli
    messages = list(messages_iterator)
               ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smprince/Documents/code/nwbinspector/src/nwbinspector/_dandi_inspection.py", line 162, in inspect_dandi_file_path
    asset = dandiset.get_asset_by_path(path=dandi_file_path)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 1238, in get_asset_by_path
    (asset,) = (
    ^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 1238, in <genexpr>
    (asset,) = (
               ^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 1191, in get_assets_with_path_prefix
    f"{self.version_api_path}assets/",
       ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 912, in version_api_path
    return f"/dandisets/{self.identifier}/versions/{self.version_id}/"
                                                    ^^^^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 832, in version_id
    self._version_id = self.version.identifier
                       ^^^^^^^^^^^^
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 840, in version
    self._get_data()
  File "/Users/smprince/anaconda3/envs/nwbinspector/lib/python3.12/site-packages/dandi/dandiapi.py", line 825, in _get_data
    raise NotFoundError(f"No such Dandiset: {self.identifier}")
dandi.exceptions.NotFoundError: No such Dandiset: https

Operating System

M1 macOS

Python Version

3.12

Were you streaming with ROS3?

No

Package Versions

Copy and paste your output here

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • Have you ensured this bug was not already reported?
  • To the best of your ability, have you ensured this is a bug within the code that checks the NWBFile, rather than a bug in the NWBFile reader (e.g., PyNWB or MatNWB)?
@stephprince stephprince added the category: bug errors in the code or code behavior label Jan 29, 2025
@stephprince stephprince self-assigned this Jan 29, 2025
@stephprince
Copy link
Contributor Author

stephprince commented Jan 29, 2025

I think this should be resolved by updating these lines:

# Scan a single NWB file in a Dandiset
elif stream and ":" in path:

to:

elif stream and ":" in path and not path_is_url:

I can make the related PR and tests.

@stephprince stephprince linked a pull request Jan 30, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: bug errors in the code or code behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant