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

get_metadata broken for some dandisets #1181

Closed
bendichter opened this issue Dec 26, 2022 · 2 comments
Closed

get_metadata broken for some dandisets #1181

bendichter opened this issue Dec 26, 2022 · 2 comments

Comments

@bendichter
Copy link
Member

Looking for data with LFP, I'd like to be able to run:

from dandi.dandiapi import DandiAPIClient

ids = [
    dandiset.identifier 
    for dandiset in DandiAPIClient().get_dandisets() 
    if 'LFP' in dandiset.get_metadata().assetsSummary.variableMeasured
]

but currently this outputs an error because the metadata object cannot be constructed for all dandisets:

---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
Input In [18], in <cell line: 3>()
      1 from dandi.dandiapi import DandiAPIClient
----> 3 ids = [
      4     dandiset.identifier 
      5     for dandiset in DandiAPIClient().get_dandisets() 
      6     if 'LFP' in dandiset.get_metadata().assetsSummary.variableMeasured
      7 ]

Input In [18], in <listcomp>(.0)
      1 from dandi.dandiapi import DandiAPIClient
      3 ids = [
      4     dandiset.identifier 
      5     for dandiset in DandiAPIClient().get_dandisets() 
----> 6     if 'LFP' in dandiset.get_metadata().assetsSummary.variableMeasured
      7 ]

File /opt/conda/lib/python3.10/site-packages/dandi/dandiapi.py:930, in RemoteDandiset.get_metadata(self)
    925 def get_metadata(self) -> models.Dandiset:
    926     """
    927     Fetch the metadata for this version of the Dandiset as a
    928     `dandischema.models.Dandiset` instance
    929     """
--> 930     return models.Dandiset.parse_obj(self.get_raw_metadata())

File /opt/conda/lib/python3.10/site-packages/pydantic/main.py:526, in pydantic.main.BaseModel.parse_obj()

File /opt/conda/lib/python3.10/site-packages/pydantic/main.py:342, in pydantic.main.BaseModel.__init__()

ValidationError: 1 validation error for Dandiset
license
  ensure this value has at least 1 items (type=value_error.list.min_items; limit_value=1)

I will try to use get_raw_metadata as a work-around, but I suspect the metadata object is the preferred access pattern.

@bendichter
Copy link
Member Author

I suspect this is connected to re-generating metadata using the new schema

@yarikoptic
Copy link
Member

#1189 seems of the same kind or even a duplicate of this one and @jwodder noted that indeed get_raw_metadata to be used if not carrying about validity of the metadata record. Feel free to reopen if you feel that smth needs to be done differently.

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

No branches or pull requests

2 participants