Skip to content

Commit

Permalink
🎨 Some minor polish on the download command
Browse files Browse the repository at this point in the history
  • Loading branch information
atonderski committed Jul 27, 2023
1 parent e0e938b commit 05dee2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "zod"
version = "0.3.2"
version = "0.3.3"
description = "Zenseact Open Dataset"
authors = ["Zenseact <opendataset@zenseact.com>"]
license = "MIT"
Expand Down
20 changes: 9 additions & 11 deletions zod/cli/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@ def _download_and_extract(dbx: ResumableDropbox, info: DownloadExtractInfo):
tqdm.write(f"{data_name} already exists. Skipping download and extraction.")
should_extract = False
else:
tqdm.write(f"File {data_name} already exists. Skipping download.")
tqdm.write(f"{data_name} already exists. Skipping download.")
elif info.dry_run:
typer.echo(f"Would download {info.file_path} to {download_path}")
msg = "download" if not should_extract else "download and extract"
typer.echo(f"Would {msg} {info.file_path} to {download_path}")
return
else:
try:
_download(download_path, dbx, info)
Expand All @@ -219,15 +221,11 @@ def _download_and_extract(dbx: ResumableDropbox, info: DownloadExtractInfo):
return

if should_extract:
if info.dry_run:
typer.echo(f"Would extract {data_name} to {info.extract_dir}")
try:
_extract(download_path, info.extract_dir)
except Exception as e:
print(f"Error extracting {data_name}: {e}. Please retry")
return
else:
try:
_extract(download_path, info.extract_dir)
except Exception as e:
print(f"Error extracting {data_name}: {e}. Please retry")
return

if info.rm and not info.dry_run:
os.remove(download_path)
Expand Down Expand Up @@ -392,7 +390,7 @@ def download(
),
parallel: bool = typer.Option(True, help="Download files in parallel", rich_help_panel=GEN),
max_workers: int = typer.Option(
8, help="Max number of workers for parallel downloads", rich_help_panel=GEN
None, help="Max number of workers for parallel downloads", rich_help_panel=GEN
),
no_confirm: bool = typer.Option(
False,
Expand Down

0 comments on commit 05dee2f

Please sign in to comment.