dandi / dandi/dandi-cli

api request: asset blob id to asset/dandiset/version

Open
#1,671 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
28
Forks
37
Avg merge
1d 17h
Merged PRs (30d)
9

Description

I need to build a map from asset blob id to dandiset(s). Currently, I am doing this by:

```python
client = DandiAPIClient()

with shelve.open("asset_blob_to_dandiset") as db:
for dandiset in tqdm(list(client.get_dandisets()), position=1):
for version in tqdm(list(dandiset.get_versions()), position=2, leave=False):
dandiset = client.get_dandiset(dandiset_id=dandiset.identifier, version_id=version.identifier)
for asset in tqdm(list(dandiset.get_assets()), position=3, leave=False):
blob_id = asset.zarr if ".zarr" in pathlib.Path(asset.path).suffixes else asset.blob
db[blob_id] = dandiset.identifier
```

This works, but feels terrible inefficient because I really only need the map for a subset of assets, but since I don't know which dandisets they belong to I am forced to iterate over all of them in order to create a reverse map. It would be great if I could have an endpoint like `assets/blob/{blob_id}/` which would return asset metadata. Ideally, this would include the ids of each dandiset that contains this asset and versions within each of those dandisets that contain this asset.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.