Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Update lincbrain --preserve-tree flag from upstream dandi, resolve etelemetry error #60

Merged
merged 4 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion docs/source/cmdline/download.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Options
.. option:: --preserve-tree

When downloading only part of a Dandiset, also download
:file:`dandiset.yaml` and do not strip leading directories from asset
:file:`dandiset.yaml` (unless downloading an asset URL that does not
include a Dandiset ID) and do not strip leading directories from asset
paths. Implies ``--download all``.

.. option:: --sync
Expand Down
3 changes: 2 additions & 1 deletion lincbrain/cli/cmd_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
is_flag=True,
help=(
"When downloading only part of a Dandiset, also download"
" `dandiset.yaml` and do not strip leading directories from asset"
" `dandiset.yaml` (unless downloading an asset URL that does not"
" include a Dandiset ID) and do not strip leading directories from asset"
" paths. Implies `--download all`."
),
)
Expand Down
13 changes: 8 additions & 5 deletions lincbrain/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,14 @@ def download_generator(self) -> Iterator[dict]:

with self.url.navigate(strict=True) as (client, dandiset, assets):
if (
isinstance(self.url, DandisetURL)
or self.is_dandiset_yaml()
or self.preserve_tree
) and self.get_metadata:
assert dandiset is not None
(
isinstance(self.url, DandisetURL)
or self.is_dandiset_yaml()
or self.preserve_tree
)
and self.get_metadata
and dandiset is not None
):
for resp in _populate_dandiset_yaml(
self.output_path, dandiset, self.existing
):
Expand Down
9 changes: 9 additions & 0 deletions lincbrain/tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,15 @@ def test_download_asset_id_only(text_dandiset: SampleDandiset, tmp_path: Path) -
assert (tmp_path / "coconut.txt").read_text() == "Coconut\n"


def test_download_asset_id_only_preserve_tree(
text_dandiset: SampleDandiset, tmp_path: Path
) -> None:
asset = text_dandiset.dandiset.get_asset_by_path("subdir2/coconut.txt")
download(asset.base_download_url, tmp_path, preserve_tree=True)
assert list_paths(tmp_path, dirs=False) == [tmp_path / "subdir2" / "coconut.txt"]
assert (tmp_path / "subdir2" / "coconut.txt").read_text() == "Coconut\n"


def test_download_asset_by_equal_prefix(
text_dandiset: SampleDandiset, tmp_path: Path
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion lincbrain/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def check_dandi_version() -> None:

try:
etelemetry.check_available_version(
"linc/linc-cli", __version__, lgr=lgr, raise_exception=True
"lincbrain/linc-cli", __version__, lgr=lgr, raise_exception=True
)
except etelemetry.client.BadVersionError:
# note: SystemExit is based of BaseException, so is not Exception
Expand Down
Loading