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

Add progress bar to fetching FloatSeries and StringSeries #1633

Merged
merged 23 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b6a72f2
add fetching with iterators (#1585)
AleksanderWWW Dec 6, 2023
7b38f74
Add limit parameter to fetch_*_table (#1593)
AleksanderWWW Dec 11, 2023
57ce683
Sorting for `fetch_*_table` (#1595)
AleksanderWWW Dec 15, 2023
48eaf74
fix sorting bug (#1601)
AleksanderWWW Dec 18, 2023
3eedaad
Add `ascending` parameter to `fetch_*_table` (#1602)
AleksanderWWW Dec 18, 2023
825d796
Progress bars in `fetch_*_table` (#1599)
AleksanderWWW Jan 18, 2024
626f029
Better value validation for state parameter of `fetch_*_table` (#1616)
Raalsky Jan 19, 2024
9faf34c
Update src/neptune/metadata_containers/model.py
Raalsky Jan 22, 2024
6974b0d
Update src/neptune/metadata_containers/model.py
Raalsky Jan 22, 2024
6ab7e7b
Use simple instead of atomic phrasing
Raalsky Jan 22, 2024
b55f223
docstring review
Raalsky Jan 22, 2024
3afb7f5
Suggestions reapplied
Raalsky Jan 22, 2024
eeafb4d
docstrings review 2
Raalsky Jan 22, 2024
95ae406
docstring proposition for ProgressBarCallback
AleksanderWWW Jan 22, 2024
54ed8f4
docstring adjustments
normandy7 Jan 22, 2024
5ed4e32
Docstrings fixes
Raalsky Jan 23, 2024
7ef63a2
Use progress bar in downloading File and FileSet (#1620)
AleksanderWWW Feb 5, 2024
8b50b2e
Add progress bar to fetching FloatSeries and StringSeries
AleksanderWWW Feb 5, 2024
3542188
changelog
AleksanderWWW Feb 5, 2024
57593d1
take the first fetch into account
AleksanderWWW Feb 5, 2024
7c4c713
Update CHANGELOG.md
AleksanderWWW Feb 6, 2024
c642100
Merge branch 'dev/fetch-ui-parity' into aw/progress-bar-for-series
AleksanderWWW Feb 6, 2024
15090d3
Update CHANGELOG.md
AleksanderWWW Feb 6, 2024
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 @@ -8,6 +8,7 @@
- Added `ascending` parameter to `fetch_*_table()` methods ([#1602](https://github.com/neptune-ai/neptune-client/pull/1602))
- Added `progress_bar` parameter to `fetch_*_table()` methods ([#1599](https://github.com/neptune-ai/neptune-client/pull/1599))
- Added `progress_bar` parameter to `download()` method of the `Handler` class ([#1620](https://github.com/neptune-ai/neptune-client/pull/1620))
- Added `progress_bar` parameter to `fetch_values()` method of the `Handler` class ([#1633](https://github.com/neptune-ai/neptune-client/pull/1633))

### Fixes
- Add direct requirement of `typing-extensions` ([#1586](https://github.com/neptune-ai/neptune-client/pull/1586))
Expand Down
18 changes: 13 additions & 5 deletions src/neptune/attributes/series/fetchable_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from typing import (
Dict,
Generic,
Optional,
TypeVar,
Union,
)
Expand All @@ -28,6 +29,9 @@
FloatSeriesValues,
StringSeriesValues,
)
from neptune.internal.backends.utils import construct_progress_bar
from neptune.internal.utils.paths import path_to_str
from neptune.typing import ProgressBarType

Row = TypeVar("Row", StringSeriesValues, FloatSeriesValues)

Expand All @@ -37,7 +41,7 @@ class FetchableSeries(Generic[Row]):
def _fetch_values_from_backend(self, offset, limit) -> Row:
pass

def fetch_values(self, *, include_timestamp=True):
def fetch_values(self, *, include_timestamp: bool = True, progress_bar: Optional[ProgressBarType] = None):
import pandas as pd

limit = 1000
Expand All @@ -53,10 +57,14 @@ def make_row(entry: Row) -> Dict[str, Union[str, float, datetime]]:
row["timestamp"] = datetime.fromtimestamp(entry.timestampMillis / 1000)
return row

while offset < val.totalItemCount:
batch = self._fetch_values_from_backend(offset, limit)
data.extend(batch.values)
offset += limit
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
while offset < val.totalItemCount:
batch = self._fetch_values_from_backend(offset, limit)
data.extend(batch.values)
offset += limit
bar.update(by=len(batch.values), total=val.totalItemCount)

rows = dict((n, make_row(entry)) for (n, entry) in enumerate(data))

Expand Down
13 changes: 11 additions & 2 deletions src/neptune/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ def fetch_last(self):
"""
return self._pass_call_to_attr(function_name="fetch_last")

def fetch_values(self, *, include_timestamp: Optional[bool] = True):
def fetch_values(self, *, include_timestamp: Optional[bool] = True, progress_bar: Optional[ProgressBarType] = None):
"""Fetches all values stored in the series from Neptune.

Available for the following field types:
Expand All @@ -568,14 +568,23 @@ def fetch_values(self, *, include_timestamp: Optional[bool] = True):
Args:
include_timestamp (bool, optional): Whether the fetched data should include the timestamp field.
Defaults to `True`.
progress_bar: (bool or Type of progress bar, optional): progress bar to be used while fetching values.
If `None` or `True` the default tqdm-based progress bar will be used.
If `False` no progress bar will be used.
If a type of progress bar is passed, it will be used instead of the default one.
Defaults to `None`.

Returns:
``Pandas.DataFrame``: containing all the values and their indexes stored in the series field.

For more information on field types, see the docs:
https://docs.neptune.ai/api-reference/field-types
"""
return self._pass_call_to_attr(function_name="fetch_values", include_timestamp=include_timestamp)
return self._pass_call_to_attr(
function_name="fetch_values",
include_timestamp=include_timestamp,
progress_bar=progress_bar,
)

@check_protected_paths
def delete_files(self, paths: Union[str, Iterable[str]], *, wait: bool = False) -> None:
Expand Down
9 changes: 9 additions & 0 deletions src/neptune/internal/backends/hosted_neptune_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,15 @@
AttributeType.RUN_STATE.value,
}

ATOMIC_ATTRIBUTE_TYPES = {
AttributeType.INT.value,
AttributeType.FLOAT.value,
AttributeType.STRING.value,
AttributeType.BOOL.value,
AttributeType.DATETIME.value,
AttributeType.RUN_STATE.value,
}


class HostedNeptuneBackend(NeptuneBackend):
def __init__(self, credentials: Credentials, proxies: Optional[Dict[str, str]] = None):
Expand Down
Loading