Skip to content

Commit

Permalink
Remove Junk metadata when script runs (#1083)
Browse files Browse the repository at this point in the history
* Remove Junk metadata when script runs

* Apply code review suggestions
  • Loading branch information
PatrykGala authored and Pavel Sankin committed Nov 17, 2022
1 parent 4705d62 commit 3c6ed87
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/neptune/management/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ class BadRequestException(ManagementOperationFailure):
class IncorrectIdentifierException(ManagementOperationFailure):
code = 21
description = "Can not parse '{identifier}' as identifier."


class ObjectNotFound(ManagementOperationFailure):
code = 22
description = "Object not found."
3 changes: 2 additions & 1 deletion src/neptune/new/internal/backends/hosted_neptune_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
NeptuneException,
)
from neptune.common.patterns import PROJECT_QUALIFIED_NAME_PATTERN
from neptune.management.exceptions import ObjectNotFound
from neptune.new.envs import NEPTUNE_FETCH_TABLE_STEP_SIZE
from neptune.new.exceptions import (
AmbiguousProjectName,
Expand Down Expand Up @@ -303,7 +304,7 @@ def get_metadata_container(
)

return ApiExperiment.from_experiment(experiment)
except HTTPNotFound:
except ObjectNotFound:
raise MetadataContainerNotFound.of_container_type(
container_type=expected_container_type, container_id=container_id
)
Expand Down
5 changes: 5 additions & 0 deletions src/neptune/new/internal/backends/swagger_client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ApiMethodWrapper:
PROJECT_NAME_COLLISION = "PROJECT_NAME_COLLISION"
PROJECT_KEY_INVALID = "PROJECT_KEY_INVALID"
PROJECT_NAME_INVALID = "PROJECT_NAME_INVALID"
EXPERIMENT_NOT_FOUND = "EXPERIMENT_NOT_FOUND"

def __init__(self, api_method):
self._api_method = api_method
Expand Down Expand Up @@ -78,6 +79,10 @@ def handle_neptune_http_errors(response, exception: Optional[HTTPError] = None):
raise ProjectNameInvalid(
name=body.get("name", "<unknown name>"), reason=body.get("reason", "Unknown reason")
) from exception
elif error_type == ApiMethodWrapper.EXPERIMENT_NOT_FOUND:
from neptune.management.exceptions import ObjectNotFound

raise ObjectNotFound() from exception
elif exception:
raise exception

Expand Down
11 changes: 11 additions & 0 deletions tests/neptune/new/client/abstract_experiment_test_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ def test_wrong_per_type_function(self):
with self.assertRaises(TypeDoesNotSupportAttributeException):
exp["some/path"].download()

def test_clean_data_on_stop(self):
exp = self.call_init(mode="async", flush_period=0.5)
container_path = exp._op_processor._queue._dir_path

assert os.path.exists(container_path)

exp.stop()

assert not os.path.exists(container_path)
assert not os.path.exists(container_path.parent)

@abstractmethod
def test_read_only_mode(self):
pass

0 comments on commit 3c6ed87

Please sign in to comment.