Skip to content

Commit

Permalink
Use literals instead of str for Mode typing and typing-extensions a…
Browse files Browse the repository at this point in the history
…dded as a direct requirement (#1586)
  • Loading branch information
Raalsky authored Dec 5, 2023
1 parent d91f1d1 commit 7bc211d
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## [UNRELEASED] 1.8.7

### Fixes
- Add direct requirement of `typing-extensions` ([#1586](https://github.com/neptune-ai/neptune-client/pull/1586))

### Changes
- Use literals instead of str for Mode typing ([#1586](https://github.com/neptune-ai/neptune-client/pull/1586))


## 1.8.6

### Fixes
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ python = "^3.7"

# Python lack of functionalities from future versions
importlib-metadata = { version = "*", python = "<3.8" }
typing-extensions = ">=3.10.0"

# Missing compatibility layer between Python 2 and Python 3
six = ">=1.12.0"
Expand Down
6 changes: 4 additions & 2 deletions src/neptune/metadata_containers/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
Optional,
)

from typing_extensions import Literal

from neptune.attributes.constants import SYSTEM_NAME_ATTRIBUTE_PATH
from neptune.common.exceptions import NeptuneException
from neptune.envs import CONNECTION_MODE
Expand Down Expand Up @@ -90,7 +92,7 @@ class Model(MetadataContainer):
mode: Connection mode in which the tracking will work.
If `None` (default), the value of the NEPTUNE_MODE environment variable is used.
If no value was set for the environment variable, "async" is used by default.
Possible values are `async`, `sync`, `offline`, `read-only`, and `debug`.
Possible values are `async`, `sync`, `read-only`, and `debug`.
flush_period: In the asynchronous (default) connection mode, how often disk flushing is triggered
(in seconds).
proxies: Argument passed to HTTP calls made via the Requests library, as dictionary of strings.
Expand Down Expand Up @@ -166,7 +168,7 @@ def __init__(
key: Optional[str] = None,
project: Optional[str] = None,
api_token: Optional[str] = None,
mode: Optional[str] = None,
mode: Optional[Literal["async", "sync", "read-only", "debug"]] = None,
flush_period: float = DEFAULT_FLUSH_PERIOD,
proxies: Optional[dict] = None,
async_lag_callback: Optional[NeptuneObjectCallback] = None,
Expand Down
6 changes: 4 additions & 2 deletions src/neptune/metadata_containers/model_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
Optional,
)

from typing_extensions import Literal

from neptune.attributes.constants import (
SYSTEM_NAME_ATTRIBUTE_PATH,
SYSTEM_STAGE_ATTRIBUTE_PATH,
Expand Down Expand Up @@ -87,7 +89,7 @@ class ModelVersion(MetadataContainer):
mode: Connection mode in which the tracking will work.
If None (default), the value of the NEPTUNE_MODE environment variable is used.
If no value was set for the environment variable, "async" is used by default.
Possible values are `async`, `sync`, `offline`, `read-only`, and `debug`.
Possible values are `async`, `sync`, `read-only`, and `debug`.
flush_period: In the asynchronous (default) connection mode, how often disk flushing is triggered
(in seconds).
proxies: Argument passed to HTTP calls made via the Requests library, as dictionary of strings.
Expand Down Expand Up @@ -166,7 +168,7 @@ def __init__(
model: Optional[str] = None,
project: Optional[str] = None,
api_token: Optional[str] = None,
mode: Optional[str] = None,
mode: Optional[Literal["async", "sync", "read-only", "debug"]] = None,
flush_period: float = DEFAULT_FLUSH_PERIOD,
proxies: Optional[dict] = None,
async_lag_callback: Optional[NeptuneObjectCallback] = None,
Expand Down
6 changes: 4 additions & 2 deletions src/neptune/metadata_containers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
Union,
)

from typing_extensions import Literal

from neptune.common.exceptions import NeptuneException
from neptune.envs import CONNECTION_MODE
from neptune.exceptions import InactiveProjectException
Expand Down Expand Up @@ -72,7 +74,7 @@ class Project(MetadataContainer):
mode: Connection mode in which the tracking will work.
If left empty, the value of the NEPTUNE_MODE environment variable is used.
If no value was set for the environment variable, "async" is used by default.
Possible values are `async`, `sync`, `offline`, `read-only`, and `debug`.
Possible values are `async`, `sync`, `read-only`, and `debug`.
flush_period: In the asynchronous (default) connection mode, how often disk flushing is triggered.
Defaults to 5 (every 5 seconds).
proxies: Argument passed to HTTP calls made via the Requests library, as dictionary of strings.
Expand Down Expand Up @@ -136,7 +138,7 @@ def __init__(
project: Optional[str] = None,
*,
api_token: Optional[str] = None,
mode: Optional[str] = None,
mode: Optional[Literal["async", "sync", "read-only", "debug"]] = None,
flush_period: float = DEFAULT_FLUSH_PERIOD,
proxies: Optional[dict] = None,
async_lag_callback: Optional[NeptuneObjectCallback] = None,
Expand Down
4 changes: 3 additions & 1 deletion src/neptune/metadata_containers/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
Union,
)

from typing_extensions import Literal

from neptune.attributes.constants import (
SYSTEM_DESCRIPTION_ATTRIBUTE_PATH,
SYSTEM_FAILED_ATTRIBUTE_PATH,
Expand Down Expand Up @@ -309,7 +311,7 @@ def __init__(
project: Optional[str] = None,
api_token: Optional[str] = None,
custom_run_id: Optional[str] = None,
mode: Optional[str] = None,
mode: Optional[Literal["async", "sync", "offline", "read-only", "debug"]] = None,
name: Optional[str] = None,
description: Optional[str] = None,
tags: Optional[Union[List[str], str]] = None,
Expand Down

0 comments on commit 7bc211d

Please sign in to comment.