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

Fix crashing syncing thread when logging big integers #1336

Merged
merged 3 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
### Features
- Series objects accept `timestamps` and `steps` in their constructors ([#1318](https://github.com/neptune-ai/neptune-client/pull/1318))

### Fixes
- Print warning instead of crashing syncing thread when logging big integers ([#1336](https://github.com/neptune-ai/neptune-client/pull/1336))

## neptune 1.1.1

### Fixes
Expand Down
17 changes: 17 additions & 0 deletions src/neptune/attributes/atoms/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@
from neptune.attributes.atoms.copiable_atom import CopiableAtom
from neptune.internal.container_type import ContainerType
from neptune.internal.operation import AssignInt
from neptune.internal.utils.logger import logger
from neptune.types.atoms.integer import Integer as IntegerVal

if typing.TYPE_CHECKING:
from neptune.internal.backends.neptune_backend import NeptuneBackend


class Integer(CopiableAtom):

MAX_32_BIT_INT = 2147483647
MIN_32_BIT_INT = -2147483648

@staticmethod
def create_assignment_operation(path, value: int):
return AssignInt(path, value)
Expand All @@ -45,5 +50,17 @@ def assign(self, value: typing.Union[IntegerVal, float, int], *, wait: bool = Fa
if not isinstance(value, IntegerVal):
value = IntegerVal(value)

if value.value < Integer.MIN_32_BIT_INT or value.value > Integer.MAX_32_BIT_INT:
logger.warning(
"WARNING: The value you're trying to log is outside the range of 32-bit integers "
"(%s to %s) and will be skipped. "
"We'll support 64-bit integers in the future. "
'For now, try logging the value as a float instead: run["field"] = float(%s)',
Integer.MIN_32_BIT_INT,
Integer.MAX_32_BIT_INT,
value.value,
)
return
Raalsky marked this conversation as resolved.
Show resolved Hide resolved

with self._container.lock():
self._enqueue_operation(self.create_assignment_operation(self._path, value.value), wait=wait)