Skip to content

Commit

Permalink
disable neptune model (#1701)
Browse files Browse the repository at this point in the history
Co-authored-by: Szymon Sadkowski <szymon.sadkowski@neptune.ai>
Co-authored-by: Sabine <sabine.nyholm@neptune.ai>
  • Loading branch information
3 people authored Mar 25, 2024
1 parent a8f3d95 commit d1be412
Show file tree
Hide file tree
Showing 15 changed files with 237 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Renamed `metadata_containers` to `objects` ([#1696](https://github.com/neptune-ai/neptune-client/pull/1696))
- Removed `neptune-client` ([#1699](https://github.com/neptune-ai/neptune-client/pull/1699))
- Deleted `neptune.logging` package ([#1698](https://github.com/neptune-ai/neptune-client/pull/1698))
- Disabled `Model` ([#1701](https://github.com/neptune-ai/neptune-client/pull/1701))

### Features
- ?
Expand Down
14 changes: 14 additions & 0 deletions src/neptune/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"NeptuneUserApiInputException",
"NeptuneMaxDiskUtilizationExceeded",
"NeptuneInvalidQueryException",
"NeptuneUnsupportedFunctionalityException",
]

from typing import (
Expand Down Expand Up @@ -1163,3 +1164,16 @@ def __init__(self, nql_query: str):
For syntax help, see https://docs.neptune.ai/usage/nql/
"""
super().__init__(message)


class NeptuneUnsupportedFunctionalityException(NeptuneException):
def __init__(self):
message = """
{h1}
----NeptuneUnsupportedFunctionalityException----------------------------
{end}
You're using neptune 2.0, which is in Beta.
Some functionality that you tried to use is not supported in the installed version.
We will gradually add missing features to the Beta. Check that you're on the latest version.
"""
super().__init__(message)
4 changes: 4 additions & 0 deletions src/neptune/objects/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
NeptuneMissingRequiredInitParameter,
NeptuneModelKeyAlreadyExistsError,
NeptuneObjectCreationConflict,
NeptuneUnsupportedFunctionalityException,
)
from neptune.internal.backends.api_model import ApiExperiment
from neptune.internal.backends.nql import (
Expand Down Expand Up @@ -181,6 +182,9 @@ def __init__(
async_no_progress_callback: Optional[NeptuneObjectCallback] = None,
async_no_progress_threshold: float = ASYNC_NO_PROGRESS_THRESHOLD,
):
# not yet supported by the backend
raise NeptuneUnsupportedFunctionalityException

verify_type("with_id", with_id, (str, type(None)))
verify_type("name", name, (str, type(None)))
verify_type("key", key, (str, type(None)))
Expand Down
21 changes: 20 additions & 1 deletion tests/e2e/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,30 @@

import inspect

import pytest
from faker import Faker

from neptune.exceptions import NeptuneUnsupportedFunctionalityException

fake = Faker()

AVAILABLE_CONTAINERS = ["project", "run", "model", "model_version"]
AVAILABLE_CONTAINERS = ["project", "run"]
AVAILABLE_CONTAINERS = [
pytest.param("project"),
pytest.param("run"),
pytest.param(
"model",
marks=pytest.mark.xfail(
reason="Model not implemented", strict=True, raises=NeptuneUnsupportedFunctionalityException
),
),
pytest.param(
"model_version",
marks=pytest.mark.xfail(
reason="Model not implemented", strict=True, raises=NeptuneUnsupportedFunctionalityException
),
),
]


class BaseE2ETest:
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def container_fn_scope(request, environment):

@pytest.fixture(scope="session")
def containers_pair(request, environment):
container_a_type, container_b_type = request.param.split("-")
container_a_type, container_b_type = request.param
container_a = initialize_container(container_type=container_a_type, project=environment.project)
container_b = initialize_container(container_type=container_b_type, project=environment.project)

Expand Down
51 changes: 43 additions & 8 deletions tests/e2e/management/test_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
Project,
init_model_version,
)
from neptune.exceptions import NeptuneUnsupportedFunctionalityException
from neptune.internal.container_type import ContainerType
from neptune.management import (
ProjectVisibility,
Expand Down Expand Up @@ -436,6 +437,25 @@ def test_trash_objects_wrong_project(self):
with pytest.raises(ProjectNotFound):
trash_objects("org/non-existent-project", ["RUN-1", "RUN-2", "RUN-3"])

def test_trash_runs(self, project, environment):
run1_id = initialize_container(ContainerType.RUN, project=environment.project)["sys/id"].fetch()
run2_id = initialize_container(ContainerType.RUN, project=environment.project)["sys/id"].fetch()
# wait for elastic index to refresh
self.wait_for_containers([run1_id, run2_id], project.fetch_runs_table)

# WHEN trash one run and one model
trash_objects(environment.project, [run1_id])

# THEN trashed runs are not fetched
self.wait_for_containers([run2_id], project.fetch_runs_table)

# WHEN trash the other run
trash_objects(environment.project, [run2_id])

# THEN no runs are fetched
self.wait_for_containers([], project.fetch_runs_table)

@pytest.mark.xfail(reason="Model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException)
def test_trash_runs_and_models(self, project, environment):
# WITH runs and models
run1_id = initialize_container(ContainerType.RUN, project=environment.project)["sys/id"].fetch()
Expand All @@ -454,6 +474,7 @@ def test_trash_runs_and_models(self, project, environment):
# AND trashed models are not fetched
self.wait_for_containers([model2_id], project.fetch_models_table)

@pytest.mark.xfail(reason="Model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException)
def test_trash_model_version(self, environment):
# WITH model
model = initialize_container(ContainerType.MODEL, project=environment.project)
Expand Down Expand Up @@ -484,22 +505,36 @@ def wait_for_containers(self, ids: List[str], container_provider: Callable[[], T

@pytest.mark.management
class TestDeleteFromTrash:
def test_delete_from_trash(self, environment):

@pytest.mark.parametrize(
("n_runs", "n_models"),
[
(2, 0),
pytest.param(
2,
1,
marks=pytest.mark.xfail(
reason="Model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException
),
),
],
)
def test_delete_from_trash(self, environment, n_runs: int, n_models: int):
# given
run1 = initialize_container(ContainerType.RUN, project=environment.project)
run2 = initialize_container(ContainerType.RUN, project=environment.project)
model = initialize_container(ContainerType.MODEL, project=environment.project)
run_id_1 = run1["sys/id"].fetch()
run_id_2 = run2["sys/id"].fetch()
model_id = model["sys/id"].fetch()
runs = [initialize_container(ContainerType.RUN, project=environment.project) for _ in range(n_runs)]
models = [initialize_container(ContainerType.MODEL, project=environment.project) for _ in range(n_models)]

run_ids = [run["sys/id"].fetch() for run in runs]
model_ids = [model["sys/id"].fetch() for model in models]
time.sleep(5)

with initialize_container(ContainerType.PROJECT, project=environment.project) as project:
trash_objects(environment.project, [run_id_1, run_id_2, model_id])
trash_objects(environment.project, run_ids + model_ids)
time.sleep(10)

# when
clear_trash(environment.project)
time.sleep(10)

# then
self.wait_for_containers_in_trash(0, 0, project)
Expand Down
28 changes: 25 additions & 3 deletions tests/e2e/standard/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,34 @@ def test_sync_should_delete_directories(self, environment, container_type):

assert not os.path.exists(container_path)

@pytest.mark.parametrize("container_type", ["model", "model_version", "project"])
@pytest.mark.parametrize(
"container_type",
[
pytest.param(
"model",
marks=pytest.mark.skip(
(
"By coincidence, the test is passing as "
"NeptuneUnsupportedFunctionalityException is subclass of NeptuneException"
)
),
),
pytest.param(
"model_version",
marks=pytest.mark.skip(
(
"By coincidence, the test is passing as "
"NeptuneUnsupportedFunctionalityException is subclass of NeptuneException"
)
),
),
"project",
],
)
def test_cannot_offline_non_runs(self, environment, container_type):
with pytest.raises(NeptuneException) as e:
with pytest.raises(NeptuneException, match=r"Project can't be initialized in OFFLINE mode"):
initialize_container(
container_type=container_type,
project=environment.project,
mode="offline",
)
assert "can't be initialized in OFFLINE mode" in str(e.value)
10 changes: 9 additions & 1 deletion tests/e2e/standard/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@
)

# List of every possible container type pair for instance: "run-run, run-model, model-model_version, ..."
ALL_CONTAINERS_PAIRS = list(map("-".join, itertools.product(AVAILABLE_CONTAINERS, AVAILABLE_CONTAINERS)))

ALL_CONTAINERS_PAIRS = list(
map(
lambda p: pytest.param(
p[0].values + p[1].values, marks=p[0].marks + p[1].marks if p[0].marks != p[1].marks else p[0].marks
),
itertools.product(AVAILABLE_CONTAINERS, AVAILABLE_CONTAINERS),
)
)


class TestCopying(BaseE2ETest):
Expand Down
34 changes: 31 additions & 3 deletions tests/e2e/standard/test_fetch_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
import pytest

import neptune
from neptune.exceptions import NeptuneInvalidQueryException
from neptune.exceptions import (
NeptuneInvalidQueryException,
NeptuneUnsupportedFunctionalityException,
)
from neptune.internal.utils.utils import IS_MACOS
from neptune.objects import Model
from tests.e2e.base import (
Expand Down Expand Up @@ -57,6 +60,7 @@ def test_fetch_runs_by_tag(self, environment, project, with_query):
assert len(runs) == 1
assert runs[0].get_attribute_value("sys/id") == run_id1

@pytest.mark.xfail(reason="Model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException)
@pytest.mark.parametrize("with_query", [True, False])
@pytest.mark.parametrize("container_fn_scope", ["model"], indirect=True)
def test_fetch_model_versions_with_correct_ids(self, container_fn_scope: Model, environment, with_query: bool):
Expand Down Expand Up @@ -154,6 +158,7 @@ def get_runs_as_rows(**kwargs):

self._test_fetch_from_container(init_run, get_runs_as_rows)

@pytest.mark.xfail(reason="Model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException)
def test_fetch_models_table(self, environment, project):
def init_run():
return neptune.init_model(project=environment.project, key=a_key())
Expand All @@ -163,7 +168,18 @@ def get_models_as_rows(**kwargs):

self._test_fetch_from_container(init_run, get_models_as_rows)

@pytest.mark.parametrize("container", ["model"], indirect=True)
@pytest.mark.parametrize(
"container",
[
pytest.param(
"model",
marks=pytest.mark.xfail(
reason="Model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException
),
)
],
indirect=True,
)
def test_fetch_model_versions_table(self, container: Model, environment):
model_sys_id = container["sys/id"].fetch()

Expand All @@ -175,7 +191,18 @@ def get_model_versions_as_rows(**kwargs):

self._test_fetch_from_container(init_run, get_model_versions_as_rows)

@pytest.mark.parametrize("container", ["model"], indirect=True)
@pytest.mark.parametrize(
"container",
[
pytest.param(
"model",
marks=pytest.mark.xfail(
reason="Model not implemented", strict=True, raises=NeptuneUnsupportedFunctionalityException
),
)
],
indirect=True,
)
def test_fetch_model_versions_table_by_query(self, container, environment):
model_sys_id = container["sys/id"].fetch()
key = "some_key"
Expand Down Expand Up @@ -387,6 +414,7 @@ def test_fetch_runs_invalid_query_handling(self, project):
with pytest.raises(NeptuneInvalidQueryException):
next(iter(runs_table))

@pytest.mark.xfail(reason="Model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException)
@pytest.mark.skipif(IS_MACOS, reason="MacOS behaves strangely on github actions")
def test_fetch_models_raw_query_trashed(self, environment, project):
# given
Expand Down
18 changes: 16 additions & 2 deletions tests/e2e/standard/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import pytest

import neptune
from neptune.exceptions import NeptuneModelKeyAlreadyExistsError
from neptune.exceptions import (
NeptuneModelKeyAlreadyExistsError,
NeptuneUnsupportedFunctionalityException,
)
from neptune.objects import (
Model,
Project,
Expand Down Expand Up @@ -184,7 +187,18 @@ def test_init_and_readonly(self, environment):


class TestInitModel(BaseE2ETest):
@pytest.mark.parametrize("container", ["model"], indirect=True)
@pytest.mark.parametrize(
"container",
[
pytest.param(
"model",
marks=pytest.mark.xfail(
reason="model is not supported", strict=True, raises=NeptuneUnsupportedFunctionalityException
),
)
],
indirect=True,
)
def test_fail_reused_model_key(self, container: Model, environment):
with pytest.raises(NeptuneModelKeyAlreadyExistsError):
model_key = container["sys/id"].fetch().split("-")[1]
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/standard/test_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def store_in_container(sys_id: str, project: str, container_type: str, destinati

class TestMultiple(BaseE2ETest):
@pytest.mark.parametrize("container", ["run"], indirect=True)
def test_single_thread(self, container: neptune.metadata_containers.NeptuneObject, environment):
def test_single_thread(self, container: neptune.Run, environment):
sys_id = container["sys/id"].fetch()
number_of_reinitialized = 5
namespace = self.gen_key()
Expand Down
Loading

0 comments on commit d1be412

Please sign in to comment.