-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Helper script to test dandi-api against girder
Well -- this one uses our machinery with logic to traverse girder folder and possibly would resolve some odd cases (e.g. multiple files per item) so is not guaranteed to not report some oddity
- Loading branch information
1 parent
5a4f24c
commit 5e043a8
Showing
1 changed file
with
43 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,43 @@ | ||
#!/usr/bin/env python3 | ||
import click | ||
import requests | ||
|
||
from dandi.dandiapi import DandiAPIClient | ||
from dandi.dandiset import APIDandiset | ||
from dandi.girder import GirderCli | ||
|
||
|
||
@click.command() | ||
def main(): | ||
g_client = GirderCli("http://3.19.164.171") | ||
a_client = DandiAPIClient("https://api.dandiarchive.org/api") | ||
|
||
with a_client.session(): | ||
g_client.dandi_authenticate() | ||
# gather all dandisets known to girder: hardcoded _id for "drafts" collection | ||
g_dandisets = list( | ||
g_client.listFolder("5e59bb0af19e820ab6ea6c62", "collection") | ||
) | ||
for dandiset, girder_id in [(x["name"], x["_id"]) for x in g_dandisets]: | ||
print(f"DANDI:{dandiset}", end="\t") | ||
g_meta, g_assets_ = g_client.get_dandiset_and_assets(girder_id, "folder") | ||
g_assets = list(g_assets_) | ||
# harmonize and get only what we care about ATM - path and size, | ||
# or otherwise we would need to query each asset for metadata | ||
g_assets_h = set((a["path"].lstrip("/"), a["size"]) for a in g_assets) | ||
|
||
a_meta, a_assets_ = a_client.get_dandiset_and_assets(dandiset, "draft") | ||
a_assets = list(a_assets_) | ||
a_assets_h = set((a["path"].lstrip("/"), a["size"]) for a in a_assets) | ||
|
||
if a_assets_h != g_assets_h: | ||
print("differs") | ||
import pdb | ||
|
||
pdb.set_trace() | ||
else: | ||
print(f"{len(a_assets)} assets the same") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |