From e79283a1077fe7c03013e3401bb559078b468cff Mon Sep 17 00:00:00 2001 From: Rafal Jankowski Date: Mon, 9 Sep 2024 12:56:20 +0200 Subject: [PATCH 1/5] chore: Dedicated exceptions for lack of project or api token --- CHANGELOG.md | 1 + src/neptune_scale/__init__.py | 10 ++++++++-- src/neptune_scale/exceptions.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a2f03f33..2a42c5bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added docstrings to logging methods ([#40](https://github.com/neptune-ai/neptune-client-scale/pull/40)) +- Dedicated exceptions for missing project or api token ([]()) ### Changed - Removed `timestamp` parameter from `add_tags()`, `remove_tags()` and `log_configs()` methods ([#37](https://github.com/neptune-ai/neptune-client-scale/pull/37)) diff --git a/src/neptune_scale/__init__.py b/src/neptune_scale/__init__.py index 6014cab4..2bc91f16 100644 --- a/src/neptune_scale/__init__.py +++ b/src/neptune_scale/__init__.py @@ -61,6 +61,10 @@ API_TOKEN_ENV_NAME, PROJECT_ENV_NAME, ) +from neptune_scale.exceptions import ( + NeptuneApiTokenNotProvided, + NeptuneProjectNotProvided, +) from neptune_scale.parameters import ( MAX_EXPERIMENT_NAME_LENGTH, MAX_FAMILY_LENGTH, @@ -167,12 +171,14 @@ def __init__( raise ValueError("`max_queue_size` must be greater than 0.") project = project or os.environ.get(PROJECT_ENV_NAME) - verify_non_empty("project", project) + if project is None: + raise NeptuneProjectNotProvided() assert project is not None # mypy input_project: str = project api_token = api_token or os.environ.get(API_TOKEN_ENV_NAME) - verify_non_empty("api_token", api_token) + if api_token is None: + raise NeptuneApiTokenNotProvided() assert api_token is not None # mypy input_api_token: str = api_token diff --git a/src/neptune_scale/exceptions.py b/src/neptune_scale/exceptions.py index d9584c06..4036ed32 100644 --- a/src/neptune_scale/exceptions.py +++ b/src/neptune_scale/exceptions.py @@ -34,6 +34,8 @@ "NeptuneStringSetExceedsSizeLimit", "NeptuneSynchronizationStopped", "NeptuneAsyncLagThresholdExceeded", + "NeptuneProjectNotProvided", + "NeptuneApiTokenNotProvided", ) from typing import Any @@ -492,3 +494,31 @@ class NeptuneAsyncLagThresholdExceeded(NeptuneScaleError): Struggling with the formatting? To disable it, set the `NEPTUNE_DISABLE_COLORS` environment variable to `True`. """ + + +class NeptuneProjectNotProvided(NeptuneRetryableError): + message = """ +{h1} +----NeptuneProjectNotProvided-------------------------------------------------- +{end} +The project name was not provided. Make sure to specify the project name in the `project` parameter of the `Run` +constructor or with `NEPTUNE_PROJECT` environment variable. + +{correct}Need help?{end}-> Contact support@neptune.ai + +Struggling with the formatting? To disable it, set the `NEPTUNE_DISABLE_COLORS` environment variable to `True`. +""" + + +class NeptuneApiTokenNotProvided(NeptuneRetryableError): + message = """ +{h1} +----NeptuneApiTokenNotProvided------------------------------------------------- +{end} +The api token was not provided. Make sure to specify the api token in the `api_token` parameter of the `Run` +constructor or with `NEPTUNE_API_TOKEN` environment variable. + +{correct}Need help?{end}-> Contact support@neptune.ai + +Struggling with the formatting? To disable it, set the `NEPTUNE_DISABLE_COLORS` environment variable to `True`. +""" From 4f175cf7bc3643ec122281b5e28a8521c6e0a432 Mon Sep 17 00:00:00 2001 From: Rafal Jankowski Date: Mon, 9 Sep 2024 12:57:15 +0200 Subject: [PATCH 2/5] CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a42c5bd..406cb177 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added docstrings to logging methods ([#40](https://github.com/neptune-ai/neptune-client-scale/pull/40)) -- Dedicated exceptions for missing project or api token ([]()) +- Dedicated exceptions for missing project or api token ([#44](https://github.com/neptune-ai/neptune-client-scale/pull/44)) ### Changed - Removed `timestamp` parameter from `add_tags()`, `remove_tags()` and `log_configs()` methods ([#37](https://github.com/neptune-ai/neptune-client-scale/pull/37)) From cfa955335fa2c47554c209fffdab666547c22242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Jankowski?= Date: Mon, 9 Sep 2024 14:40:05 +0200 Subject: [PATCH 3/5] Update CHANGELOG.md Co-authored-by: Sabine --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 406cb177..e104bafa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added docstrings to logging methods ([#40](https://github.com/neptune-ai/neptune-client-scale/pull/40)) -- Dedicated exceptions for missing project or api token ([#44](https://github.com/neptune-ai/neptune-client-scale/pull/44)) +- Dedicated exceptions for missing project or API token ([#44](https://github.com/neptune-ai/neptune-client-scale/pull/44)) ### Changed - Removed `timestamp` parameter from `add_tags()`, `remove_tags()` and `log_configs()` methods ([#37](https://github.com/neptune-ai/neptune-client-scale/pull/37)) From cffdfbc39659e701708aee59ce4bf1f2e78da281 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Jankowski?= Date: Mon, 9 Sep 2024 14:40:11 +0200 Subject: [PATCH 4/5] Update src/neptune_scale/exceptions.py Co-authored-by: Sabine --- src/neptune_scale/exceptions.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/neptune_scale/exceptions.py b/src/neptune_scale/exceptions.py index 4036ed32..69d9db6a 100644 --- a/src/neptune_scale/exceptions.py +++ b/src/neptune_scale/exceptions.py @@ -502,7 +502,9 @@ class NeptuneProjectNotProvided(NeptuneRetryableError): ----NeptuneProjectNotProvided-------------------------------------------------- {end} The project name was not provided. Make sure to specify the project name in the `project` parameter of the `Run` -constructor or with `NEPTUNE_PROJECT` environment variable. +constructor or with the `NEPTUNE_PROJECT` environment variable. + +For instructions, see https://docs-beta.neptune.ai/setup {correct}Need help?{end}-> Contact support@neptune.ai From 17d94802e14bdf5b1c17280ec71c792923723043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Jankowski?= Date: Mon, 9 Sep 2024 14:40:16 +0200 Subject: [PATCH 5/5] Update src/neptune_scale/exceptions.py Co-authored-by: Sabine --- src/neptune_scale/exceptions.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/neptune_scale/exceptions.py b/src/neptune_scale/exceptions.py index 69d9db6a..389eb1e2 100644 --- a/src/neptune_scale/exceptions.py +++ b/src/neptune_scale/exceptions.py @@ -517,8 +517,10 @@ class NeptuneApiTokenNotProvided(NeptuneRetryableError): {h1} ----NeptuneApiTokenNotProvided------------------------------------------------- {end} -The api token was not provided. Make sure to specify the api token in the `api_token` parameter of the `Run` -constructor or with `NEPTUNE_API_TOKEN` environment variable. +The Neptune API token was not provided. Make sure to specify the API token in the `api_token` parameter of the `Run` +constructor or with the `NEPTUNE_API_TOKEN` environment variable. + +For instructions, see https://docs-beta.neptune.ai/api_token {correct}Need help?{end}-> Contact support@neptune.ai