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

RF/ENH: download - reimplementation to support original and upcoming UI/API #134

Merged
merged 39 commits into from
Aug 12, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e06cbac
ENH: add API server url to the instance records
yarikoptic Jul 15, 2020
9871ece
RF: move girder specifics around
yarikoptic Jul 15, 2020
888b2e4
ENH: support parsing "dandiapi" style URLs from unversioned current D…
yarikoptic Jul 15, 2020
d647032
BF(TST): there was one not fixed earlier test with incorrect assert o…
yarikoptic Jul 15, 2020
b1539aa
BF: add /api to the API endpoint
yarikoptic Jul 16, 2020
d10fa77
RF+ENH: introduce "dandiapi" type of server to download from
yarikoptic Jul 20, 2020
2c1cc94
RF: WiP - I remember that download for girder worked
yarikoptic Jul 22, 2020
764237b
NF: IteratorWithAggregation - to help receiving/displaying total whil…
yarikoptic Jul 27, 2020
cb4c80f
NF: remap_dict helper to remap dicts from one "schema" to another
yarikoptic Jul 27, 2020
55774be
ENH/RF: remap girder dandiset into API record, centralize download+ch…
yarikoptic Jul 28, 2020
188530c
ENH: harmonize records from girder to API (+modified), both downloade…
yarikoptic Jul 28, 2020
e2bbac1
ENH(TST): a test on 000027 to ensure that both types of download work…
yarikoptic Jul 28, 2020
d291eb9
ENH: download - support DANDI: shortcuts
yarikoptic Jul 30, 2020
84fb8c4
ENH: mess of changes to get all downloads working (no parallel yet)
yarikoptic Aug 1, 2020
c56d948
ENH: parallel downloads as a tribute to more ugliness
yarikoptic Aug 1, 2020
fcfa310
BF: make friends with lint + fix one warning msg to properly include …
yarikoptic Aug 6, 2020
afea1f0
BF: girder paths are os specific so use os.path.sep instead of /
yarikoptic Aug 7, 2020
aa170d0
Merge remote-tracking branch 'origin/master' into enh-download-api
yarikoptic Aug 7, 2020
c3081e7
BF: add None for publish/api in local-docker-tests + TODO comments fo…
yarikoptic Aug 7, 2020
e4938cf
BF(TST): avoid using POSIX paths in the test to please Windows
yarikoptic Aug 7, 2020
c9d3cf2
ENH(TST): make sleeps shorter, but keep last outter sleep long
yarikoptic Aug 7, 2020
51b0743
minor: test for it.finished without explicit == True
yarikoptic Aug 7, 2020
d61295d
BF(workaround,TST): give more time for windows to react
yarikoptic Aug 7, 2020
0708d1a
Merge remote-tracking branch 'origin/master' into enh-download-api
yarikoptic Aug 10, 2020
a941485
RF: download - encapsulating some code + moving around + TODOs
yarikoptic Aug 11, 2020
19e3d77
Merge remote-tracking branch 'origin/master' into enh-download-api
yarikoptic Aug 12, 2020
aed98c5
BF: making linting happy
yarikoptic Aug 12, 2020
327881e
RF: "dandiapi" -> "api" and "DANDI API" to match /server-info simple …
yarikoptic Aug 12, 2020
a4f2a3d
BF: moved lock_dandiset into correct position (incorrect merge side e…
yarikoptic Aug 12, 2020
64d9952
BF(TST): yet one more test fix up for incorrect handling while merging
yarikoptic Aug 12, 2020
4798e49
RF: do not duplicate defaults within kwargs in @click entrypoint for …
yarikoptic Aug 12, 2020
09b2196
BF: cast env var DANDI_MAX_CHUNK_SIZE to int
yarikoptic Aug 12, 2020
f367313
BF: close the session if we started a new one
yarikoptic Aug 12, 2020
a45b550
ENH: use result.ok instead of checking only for 200 and 201
yarikoptic Aug 12, 2020
515538e
RF: dandiapi - remove not used include_metadata option
yarikoptic Aug 12, 2020
096c8dd
BF: ask for pyout != 0.6.0 so we could keep passing tuples with field…
yarikoptic Aug 12, 2020
5abd195
ENH(UX): set warn to True upon issueing first warning that we got mor…
yarikoptic Aug 12, 2020
e52d728
RF: quit loop even before the first .get if exception was raised
yarikoptic Aug 12, 2020
20718e2
RF: completely remove custom subclass HTTPError for now
yarikoptic Aug 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions dandi/cli/cmd_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
default="refresh",
show_default=True,
)
@click.option(
"-f",
"--format",
help="Choose the format/frontend for output. TODO: support all of the ls",
type=click.Choice(["pyout", "debug"]),
default="pyout",
)
@click.option(
"-J",
"--jobs",
Expand All @@ -48,12 +55,16 @@
)
@click.argument("url", nargs=-1)
@map_to_click_exceptions
def download(url, output_dir, existing, jobs=6, develop_debug=False):
def download(url, output_dir, existing, jobs=6, format="pytout"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's a situation where click would leave format unfilled, and if there is, shouldn't the default be "pyout", not "pytout"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh... so we can avoid duplicating default values within kwargs?! let met just strip then them away from download and we could do to the rest in a separate PR. THANK YOU! done in 4798e49

"""Download a file or entire folder from DANDI"""
# First boring attempt at click commands being merely an interface to
# Python function
from ..download import download

return download(
url, output_dir, existing=existing, jobs=jobs, develop_debug=develop_debug
url,
output_dir,
existing=existing,
format=format,
jobs=jobs, # develop_debug=develop_debug
)
2 changes: 1 addition & 1 deletion dandi/cli/cmd_ls.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def ls(paths, fields=None, format="auto", recursive=False):
if fields and fields[0] != "path":
# we must always have path - our "id"
fields = ["path"] + fields
out = PYOUTFormatter(files=files, fields=fields)
out = PYOUTFormatter(fields=fields)
elif format == "json":
out = JSONFormatter()
elif format == "json_pp":
Expand Down
3 changes: 1 addition & 2 deletions dandi/cli/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ def __call__(self, rec):


class PYOUTFormatter(pyout.Tabular):
def __init__(self, files, fields):
# max_filename_len = max(map(lambda x: len(op.basename(x)), files))
def __init__(self, fields):
PYOUT_STYLE = pyouts.get_style(hide_if_missing=not fields)

kw = dict(style=PYOUT_STYLE)
Expand Down
26 changes: 22 additions & 4 deletions dandi/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# A list of metadata fields which dandi extracts from .nwb files.
# Additional fields (such as `number_of_*`) might be added by the
# get_metadata`
import os

metadata_nwb_file_fields = (
"experiment_description",
"experimenter",
Expand Down Expand Up @@ -73,23 +75,31 @@
dandiset_metadata_file = "dandiset.yaml"
dandiset_identifier_regex = "^[0-9]{6}$"

dandi_instance = namedtuple("dandi_instance", ("girder", "gui", "redirector"))
dandi_instance = namedtuple("dandi_instance", ("girder", "gui", "redirector", "api"))

known_instances = {
"local-girder-only": dandi_instance(
"http://localhost:8080", None, None
"http://localhost:8080", None, None, None
), # just pure girder
# Redirector: TODO https://github.com/dandi/dandiarchive/issues/139
"local-docker": dandi_instance(
"http://localhost:8080", "http://localhost:8085", None
"http://localhost:8080",
"http://localhost:8085",
None,
"http://localhost:9000", # ATM it is minio, not sure where /api etc
# may be https://github.com/dandi/dandi-publish/pull/71 would help
),
"local-docker-tests": dandi_instance(
"http://localhost:8081", "http://localhost:8086", "http://localhost:8079"
"http://localhost:8081",
"http://localhost:8086",
"http://localhost:8079",
None, # TODO: https://github.com/dandi/dandi-cli/issues/164
),
"dandi": dandi_instance(
"https://girder.dandiarchive.org",
"https://gui.dandiarchive.org",
"https://dandiarchive.org",
"https://publish.dandiarchive.org/api", # ? might become api.
),
}
# to map back url: name
Expand All @@ -100,6 +110,14 @@

file_operation_modes = ["dry", "simulate", "copy", "move", "hardlink", "symlink"]

#
# Download (upload?) specific constants
#
# Chunk size when iterating a download (and upload) body. Taken from girder-cli
# TODO: should we make them smaller for download than for upload?
# ATM used only in download
MAX_CHUNK_SIZE = os.environ.get("DANDI_MAX_CHUNK_SIZE", 1024 * 1024 * 8) # 64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to cast this to an int, as the value from os.environ is a string.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh, right,THANKS! done in 09b2196


#
# Some routes
# TODO: possibly centralize in dandi-common from our redirection service
Expand Down
Loading