Skip to content

Commit

Permalink
Fix crashing syncing thread when logging big integers
Browse files Browse the repository at this point in the history
  • Loading branch information
aniezurawski committed May 5, 2023
1 parent ec704a9 commit 65e9f08
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/neptune/attributes/atoms/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#
__all__ = ["Integer"]

import logging
import typing

from neptune.attributes.atoms.copiable_atom import CopiableAtom
Expand All @@ -26,7 +27,14 @@
from neptune.internal.backends.neptune_backend import NeptuneBackend


_logger = logging.getLogger(__name__)


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 +53,15 @@ def assign(self, value: typing.Union[IntegerVal, float, int], *, wait: bool = Fa
if not isinstance(value, IntegerVal):
value = IntegerVal(value)

if value.value > Integer.MAX_32_BIT_INT or value.value < Integer.MIN_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

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

0 comments on commit 65e9f08

Please sign in to comment.