Skip to content

Commit

Permalink
Limit length of custom_run_id (#748)
Browse files Browse the repository at this point in the history
* Limit length of `custom_run_id`

* Limit length of `custom_run_id`

* re-black

Co-authored-by: Piotr Kasprzyk <[email protected]>
  • Loading branch information
shnela and Piotr Kasprzyk authored Nov 23, 2021
1 parent eafff2f commit 3d1e776
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 2 additions & 4 deletions neptune/new/internal/init_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
)
from neptune.new.internal.utils import verify_collection_type, verify_type
from neptune.new.internal.utils.git import discover_git_repo_location, get_git_info
from neptune.new.internal.utils.limits import custom_run_id_exceeds_length
from neptune.new.internal.utils.ping_background_job import PingBackgroundJob
from neptune.new.internal.utils.runningmode import in_interactive, in_notebook
from neptune.new.internal.utils.source_code import upload_source_code
Expand Down Expand Up @@ -249,10 +250,7 @@ def init(
if mode == Mode.READ_ONLY:
raise NeedExistingRunForReadOnlyMode()
git_ref = get_git_info(discover_git_repo_location())
if custom_run_id and len(custom_run_id) > 32:
_logger.warning(
"Given custom_run_id exceeds 32 characters and it will be ignored."
)
if custom_run_id_exceeds_length(custom_run_id):
custom_run_id = None

notebook_id, checkpoint_id = _create_notebook_checkpoint(backend)
Expand Down
11 changes: 11 additions & 0 deletions neptune/new/internal/utils/limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
_logger = logging.getLogger(__name__)


_CUSTOM_RUN_ID_LENGTH = 36
_IMAGE_SIZE_LIMIT_MB = 15
_IN_MEMORY_SIZE_LIMIT_MB = 32
_STREAM_SIZE_LIMIT_MB = 32
Expand All @@ -27,6 +28,16 @@
STREAM_SIZE_LIMIT_BYTES = _STREAM_SIZE_LIMIT_MB * BYTES_IN_MB


def custom_run_id_exceeds_length(custom_run_id):
if custom_run_id and len(custom_run_id) > _CUSTOM_RUN_ID_LENGTH:
_logger.warning(
"Given custom_run_id exceeds %s" " characters and it will be ignored.",
_CUSTOM_RUN_ID_LENGTH,
)
return True
return False


def image_size_exceeds_limit(content_size):
if content_size > _IMAGE_SIZE_LIMIT_MB * BYTES_IN_MB:
_logger.warning(
Expand Down

0 comments on commit 3d1e776

Please sign in to comment.