Skip to content

Commit

Permalink
Unexpected errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Raalsky committed Aug 19, 2024
1 parent b19dbd5 commit 1c2ca6e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/neptune_scale/core/components/errors_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
from neptune_scale.core.components.daemon import Daemon
from neptune_scale.core.logger import logger
from neptune_scale.core.process_killer import kill_me
from neptune_scale.exceptions import NeptuneOperationsQueueMaxSizeExceeded
from neptune_scale.exceptions import (
NeptuneOperationsQueueMaxSizeExceeded,
NeptuneScaleError,
NeptuneUnexpectedError,
)
from neptune_scale.parameters import ERRORS_MONITOR_THREAD_SLEEP_TIME


Expand Down Expand Up @@ -67,5 +71,7 @@ def work(self) -> None:
while (error := self.get_next()) is not None:
if isinstance(error, NeptuneOperationsQueueMaxSizeExceeded):
self._max_queue_size_exceeded_callback(error)
else:
elif isinstance(error, NeptuneScaleError):
self._on_error_callback(error)
else:
self._on_error_callback(NeptuneUnexpectedError(reason=str(type(error))))
2 changes: 1 addition & 1 deletion src/neptune_scale/core/components/operations_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def enqueue(self, *, operation: RunOperation) -> None:

with self._lock:
self._queue.put(
QueueElement(self._sequence_id, monotonic(), serialized_operation),
QueueElement(self._sequence_id, monotonic(), b"deadbeef" + serialized_operation),
block=True,
timeout=None,
)
Expand Down
17 changes: 17 additions & 0 deletions src/neptune_scale/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"NeptuneOperationsQueueMaxSizeExceeded",
"NeptuneUnauthorizedError",
"NeptuneInvalidCredentialsError",
"NeptuneUnexpectedError",
)

from typing import Any
Expand Down Expand Up @@ -104,3 +105,19 @@ class NeptuneInvalidCredentialsError(NeptuneScaleError):
Struggling with the formatting? To disable it, set the `NEPTUNE_DISABLE_COLORS` environment variable to `True`.
"""


class NeptuneUnexpectedError(NeptuneScaleError):
message = """
{h1}
----NeptuneUnexpectedError-----------------------------------------------------
{end}
An unexpected error occurred in Neptune Scale Client. Please contact Neptune.ai support. Raw exception name: "{reason}"
{correct}Need help?{end}-> https://docs.neptune.ai/getting_help
Struggling with the formatting? To disable it, set the `NEPTUNE_DISABLE_COLORS` environment variable to `True`.
"""

def __init__(self, reason: str) -> None:
super().__init__(reason=reason)

0 comments on commit 1c2ca6e

Please sign in to comment.