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

Commit

Permalink
Use units in tqdm (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderWWW authored Nov 23, 2023
1 parent 50383a4 commit 4219af4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
### Features
- Added default run name handling ([#18](https://github.com/neptune-ai/neptune-client-experimental/pull/18))

### Changes
- Add custom units and descriptions to tqdm progress bars ([#29](https://github.com/neptune-ai/neptune-client-experimental/pull/29))


## neptune-experimental 0.2.1

Expand Down
2 changes: 1 addition & 1 deletion src/neptune_fetcher/custom_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ def _get_all_items(self, get_portion, step):
previous_items = get_portion(limit=step, offset=len(items))
items += previous_items
# We don't know the size apriori
self.progress_update_handler.on_runs_table_fetch(step)
self.progress_update_handler.on_runs_table_fetch(len(previous_items))
self.progress_update_handler.post_runs_table_fetch()
return items
9 changes: 3 additions & 6 deletions src/neptune_fetcher/progress_update_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,36 +98,33 @@ class DefaultProgressUpdateHandler(ProgressUpdateHandler):
def pre_series_fetch(self, total_series: int, series_limit: int) -> None:
from tqdm import tqdm

self._series_bar = tqdm(total=total_series)
self._series_bar = tqdm(total=total_series, desc="Fetching series values", unit=" steps")
self._series_bar.update(n=series_limit)

def pre_runs_table_fetch(self) -> None:
from tqdm import tqdm

self._table_bar = tqdm()
self._table_bar = tqdm(desc="Fetching runs", unit=" runs")

def on_series_fetch(self, step: int) -> None:
self._series_bar.update(n=step)
self._series_bar.set_description("Fetching series values")

def post_series_fetch(self) -> None:
self._series_bar.close()

def on_runs_table_fetch(self, step: int) -> None:
self._table_bar.update(n=step)
self._table_bar.set_description("Fetching runs")

def post_runs_table_fetch(self) -> None:
self._table_bar.close()

def pre_download(self, total_size: int) -> None:
from tqdm import tqdm

self._download_bar = tqdm(total=total_size)
self._download_bar = tqdm(total=total_size, desc="Downloading file", unit="B", unit_scale=True)

def on_download_chunk(self, chunk: int) -> None:
self._download_bar.update(n=chunk)
self._download_bar.set_description("Downloading file")

def post_download(self) -> None:
self._download_bar.close()

0 comments on commit 4219af4

Please sign in to comment.