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

Disable progress bar for small fetchings #1638

Merged
merged 7 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -28,6 +28,7 @@
- Changed internal directories path structure ([#1606](https://github.com/neptune-ai/neptune-client/pull/1606))
- Changed format of warning messages ([#1635](https://github.com/neptune-ai/neptune-client/pull/1635))
- Make `trash_objects()` raise `ProjectNotFound` if project does not exist ([#1636](https://github.com/neptune-ai/neptune-client/pull/1636))
- Do not show progress bars when no data to fetch / small amount of data ([#1638](https://github.com/neptune-ai/neptune-client/pull/1638))


## 1.8.6
Expand Down
14 changes: 7 additions & 7 deletions src/neptune/api/searching_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@ def iter_over_pages(
searching_after = None
last_page = None

total = 0
total = get_single_page(
limit=0,
offset=0,
**kwargs,
).get("matchingItemCount", 0)

progress_bar = progress_bar if step_size >= total else None
progress_bar = False if total < step_size else progress_bar # disable progress bar if only one page is fetched
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not 100% sure but shouldn't it be <=?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


with construct_progress_bar(progress_bar, "Fetching table...") as bar:
# beginning of the first page
bar.update(
by=0,
total=get_single_page(
limit=0,
offset=0,
**kwargs,
).get("matchingItemCount", 0),
total=total,
)

while True:
Expand Down
2 changes: 2 additions & 0 deletions src/neptune/attributes/series/fetchable_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def make_row(entry: Row) -> Dict[str, Union[str, float, datetime]]:
row["timestamp"] = datetime.fromtimestamp(entry.timestampMillis / 1000)
return row

progress_bar = False if len(data) < limit else progress_bar

path = path_to_str(self._path) if hasattr(self, "_path") else ""
with construct_progress_bar(progress_bar, f"Fetching {path} values") as bar:
bar.update(by=len(data), total=val.totalItemCount) # first fetch before the loop
Expand Down
3 changes: 3 additions & 0 deletions src/neptune/internal/backends/hosted_file_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@ def _store_response_as_file(
target_file = destination

total_size = int(response.headers.get("content-length", 0))

progress_bar = False if total_size < 1024 * 1024 else progress_bar # less than one chunk
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Magic numbers 🛑
  2. Looks likecontent-length may not be provided. If I understand correctly this doesn't mean that the file is empty; rather it's not possible to determine the target size. In such a case we should probably show the progress bar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


# TODO: update syntax once py3.10 becomes min supported version (with (x(), y(), z()): ...)
with ExitStack() as stack:
bar = stack.enter_context(construct_progress_bar(progress_bar, "Fetching file..."))
Expand Down
Loading