Update for new API at https://api.dandiarchive.org/api#283
Conversation
Codecov Report
@@ Coverage Diff @@
## master #283 +/- ##
==========================================
+ Coverage 81.72% 82.52% +0.80%
==========================================
Files 54 55 +1
Lines 4979 5054 +75
==========================================
+ Hits 4069 4171 +102
+ Misses 910 883 -27
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
|
Let's add |
|
@yarikoptic I think it'd be easier to work on if it were merged into master sooner rather than later. |
|
@yarikoptic Download of what, exactly? Just one asset per method call? Any specific API? |
download of an asset, e.g. the one you would upload in the test. Yes, just one asset at a time but support multiple: given a dandiset id, and path (and possibly a version, default to
after we have that interface, it should be "integrated" into our current code/logic for
Ok, let's aim then for |
|
@dchiquit
|
|
may be you could figure out a fix for https://github.com/dandi/dandi-api @jwodder for the |
|
That endpoint was patched together to provide data for the Dandiset browser in the web UI, so it wasn't designed very thoughtfully and has some weird inconsistencies.
We never made a design decision as to whether or not paths should start with a root slash or not. We can adjust this if one implementation is better for the CLI. What exactly are you using the |
By "path", do you mean that the download function should take an exact path to a single asset file at a time, or should it also accept paths to folders? |
folders as well. logic I guess should be added to deduce if it was to an asset or a folder: if a single asset returned by API and basename matches the basename of the path in url -- it was a single asset. If multiple assets or not matching -- take basename of the url's path and that would be the folder, unless it was an empty path - so it is the top of the dandiset, use dandiset ID as the folder name |
|
@dchiquit What endpoint would you recommend for looking up the IDs and paths of all assets whose paths have a given prefix? Do I just have to filter |
|
@jwodder Yes, that's probably safer than using |
|
@jwodder Looks like we did add some rudimentary filtering, that is the https://api.dandiarchive.org/api/dandisets/000001/versions/draft/assets/?path=/ should return two assets, |
Forcing the user to use folder names they didn't ask for seems too high-level, like something that should be implemented on top of the basic download methods. Counterproposal: There are two download methods:
|
|
since asset paths are always in the namespace of the dandiset, would the following be useful:
and the function would construct something like this basedir = basedir or os.getcwd()
namespace = "dandi"
Path(basedir) / f"{namespace}-{dandiset} / f"{version}" / assetpath
and when we transition to personal dandi infrastructure, the namespace could change. we could make |
|
@satra Are you suggesting this for the path at which to download an asset? I believe that the basic download method should be low-level, allowing the user to specify whatever complete target filepath they want. |
yes my suggestion is primarily about a reasonable default. we could be returning a list of assets as the result of a search. in that scenario this could be a default local layout. for a single asset, indeed a user should be able to override the location to store the asset, but the default location could be something like the one i listed. |
I think we would want
ok, just make it plural, and again "path" not "name" since IMHO "name" is more of a "basename"? i.e. |
I would prefer to avoid custom prefixes, like |
the archive does not have a root location for a dandiset only an identifier |
|
Filed a dedicated issue #321 for that to not derail discussion here (where goal is "feature parity" ATM) |
|
@yarikoptic This PR should be done now. |
|
Looks good, and I did not spot any change which could impact operation of the client while talking with current girder-based instance, so should be good to go. Thank you @jwodder ! |
Closes #277.