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

Fix id+key reporting in cli #206

Merged
merged 1 commit into from
Jul 28, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Expand the list of exceptions on which we should retry for HTTP ([#195](https://github.com/stac-utils/stac-asset/pull/195))
- `SkipAssetDownload` docstring ([#199](https://github.com/stac-utils/stac-asset/pull/199))
- Fast failing when we hit `max_concurrent_downloads` ([#204](https://github.com/stac-utils/stac-asset/pull/204))
- Id+key reporting in CLI ([#206](https://github.com/stac-utils/stac-asset/pull/206))

## [0.4.1] - 2024-07-17

Expand Down
12 changes: 6 additions & 6 deletions src/stac_asset/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ async def report_progress(messages: Optional[MessageQueue]) -> None:
unit_divisor=1024,
)
sizes = dict()
owners = dict()
ids = dict()
assets = 0
done = 0
errors = 0
Expand All @@ -352,7 +352,9 @@ async def report_progress(messages: Optional[MessageQueue]) -> None:
if isinstance(message, StartAssetDownload):
assets += 1
if message.owner_id:
owners[message.key] = message.owner_id
ids[message.href] = f"{message.owner_id}[{message.key}]"
else:
ids[message.href] = f"[{message.key}]"
progress_bar.set_description(f"{done}/{assets}")
elif isinstance(message, OpenUrl):
if message.size:
Expand All @@ -376,10 +378,8 @@ async def report_progress(messages: Optional[MessageQueue]) -> None:
progress_bar.update(n)
progress_bar.set_postfix_str(f"{errors} errors, {skips} skips")
progress_bar.set_description_str(f"{done}/{assets}")
if message.key in owners:
name = f"{owners[message.key]}[{message.key}]"
else:
name = f"[{message.key}]"
if message.href in ids:
name = ids[message.href]
progress_bar.write(
f"ERROR: {name} - {type(message.error).__name__}: {message.error}",
file=sys.stderr,
Expand Down