Support CLI uploading & downloading via new API#330
Conversation
Codecov Report
@@ Coverage Diff @@
## master #330 +/- ##
==========================================
- Coverage 82.57% 82.35% -0.23%
==========================================
Files 55 55
Lines 5136 5598 +462
==========================================
+ Hits 4241 4610 +369
- Misses 895 988 +93
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
yarikoptic
left a comment
There was a problem hiding this comment.
initial feedback. main point - is to use new AssetMeta metadata record, and add (back) decision on either file to be reuploaded or already in a correct state in the archive.
…or girder URLs - added gui.dandiarchive.org as the one also serving "dandi-api" instance (which it does) - added ad-hoc schema for download from URLs powering API-based web UI: prepend "api+" to the URL seeing in the browser. This will go away when we flip the switch to use that new one by default. Meanwhile, while we do not have a dedicated instance running (like gui-api.dandiarchive.org) which would allow for easy mapping use this "api+" - web UI also has changed its URLs to not show girder folder IDs, so I removed that URL schema handling as well - removed mentioning of publish.dandiarchive.org which is no longer in service. - removed handling/testing of being able to download multiple files selected in web UI, since it no longer supports that, and if re-introduced would likely to be in the new API powered interface - "server_type" variable before was referring to either URL is girder or api based. Now it refers to actual server to use -- girder or api.
|
@yarikoptic Other than testing (which I'd honestly rather not be the one to do), is there anything that still needs to be done for this PR? |
Updated PR description with TODO items. And testing (as a unit/integration test; I can then test with our live instance) is exactly what we need most of all I think. |
|
Woohoo, now there is https://gui-beta-dandiarchive-org.netlify.app. Thanks to @dchiquit . Ssi we can replace that adhoc api+ url with this one |
|
@yarikoptic What URL do I use for downloading from the Docker Compose API instance? I tried |
|
I did not add mapping for direct API urls, we have only for "web UI" urls, such as |
|
@yarikoptic The Docker Compose setup does not appear to have a GUI for the new API. |
|
It does not, you would have to clone and serve it from https://github.com/dandi/dandiarchive#web-app if you really need a GUI to use the CLI. Is there a reason the CLI always requires a URL? It doesn't sound difficult to just specify a dandiset ID+version, i.e. |
|
@dchiquit in my humble attempt to simplify it for the users (just copy/paste a URL or some URI, instead of parsing/splitting to give to cli), and more formalized URIs (to include path) in addition to just |
…ce instead of api+ prefix
|
@jwodder - pushed 8ebaea6 which should support direct api calls as well now and react to https://gui-beta-dandiarchive-org.netlify.app/ instead of api+ prefix |
| # | ||
| # Upload file | ||
| # | ||
| yield {"status": "uploading"} |
There was a problem hiding this comment.
no coverage here suggests that we actually not uploaded any file... so not yet sure how test passes on CI (besides if glob is just wrong) and also for me locally test fails with
___________________________________________________ test_new_upload_download ____________________________________________________
/home/yoh/proj/dandi/dandi-cli/dandi/tests/test_upload.py:261: in test_new_upload_download
upload(
/home/yoh/proj/dandi/dandi-cli/dandi/upload.py:50: in upload
return _new_upload(
/home/yoh/proj/dandi/dandi-cli/dandi/upload.py:609: in _new_upload
ds_identifier = dandiset.identifier
/home/yoh/proj/dandi/dandi-cli/dandi/dandiset.py:107: in identifier
raise ValueError(
E ValueError: Found no dandiset.identifier in metadata record: {'sex': ['M'], 'number_of_subjects': 1, 'organism': [{'species': 'mouse'}], 'description': 'experiment_description1', 'publications': ['related_publications1']}
There was a problem hiding this comment.
In the course of fixing this, I realized that the code doesn't set the auth token for the new API anywhere. How should that be passed in/obtained?
There was a problem hiding this comment.
@dchiquit how to login/get token within the test docker compose instance of api server?
There was a problem hiding this comment.
@yarikoptic I know how to do that; the problem is how to pass the token to the upload function.
There was a problem hiding this comment.
do we get 401 response if we try to upload without authentication? if so - guard in send_request for receiving 401 and adopt GirderCli's dandi_authenticate for RESTFullAPIClient to do authentication in such cases (if was not authenticated before).
to avoid confusion etc, rename prior uses of DANDI_API_KEY to DANDI_GIRDER_API_KEY and use DANDI_API_KEY for authentication against our API server here.
There was a problem hiding this comment.
The tests & coverage should be working properly now.
There was a problem hiding this comment.
The auth token can be obtained from the web GUI by clicking on the user menu drop down and copying the API Key, same as in girder.
Specifying a Authorization: Token 123567890abcdefg header should be all that is required to use that token when making requests.
* origin/master: Add JSON Schema validation to tests Functions for validating against JSON Schemas Move publish_model_schemata() to dandi/metadata.py Fix `AttributeError: 'Resource' object has no attribute 'values'` [DATALAD RUNCMD] Swap order of str and AnyUrl to be from specific to generic ENH: allow for DeprecationWarning to come from requests_toolbelt, not our problem Fetch Django test API token more robustly
|
FTR: I have pushed a merge of master (so we have readily a version accounting for recent changes to the model etc) |
I did leave handling of old style simple "identifier: STR" for now, but later we need to RF anyways to first check the schemaVersion and act accordingly. Related issues filed at dandi-api - dandi/dandi-archive#63 -- identifier should be populated - dandi/dandi-archive#64 -- schemaVersion should be populated
Causes dandi download to fail if ran in DANDI_DEVEL=1 mode
|
pushed some minor tune ups to get going, unfortunately to obtain at the end so something is not yet working with the real S3 target bucket. attn: @jwodder @dchiquit |
|
@yarikoptic That's an error between the CLI and S3. Amazon is pretty good about including error messages, can you inspect the payload of that response? |
|
@dchiquit here is what we get in response text (sensorred with XXX) and the culprit here is seems to work but I guess would lack any additional error handling etc. |
|
@yarikoptic S3 requests now use a separate client instance. |
|
that would do it for now... fails seems to be unrelated, so let's proceed! |
Closes #320.
@yarikoptic This is still in progress, but I'd appreciate feedback on what I have so far.
TODOs:
apihigher level interface code works since no lines are coveredDandiAPIClientcode handle it properly (get the latest version, download for it)Moved two last items into a dedicated issue to follow up not here: #340