From 7b2f7a4793334034ee749ffd8f21991ab0896bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Jankowski?= Date: Mon, 27 May 2024 13:06:08 +0200 Subject: [PATCH] Get rid of printing URL and use custom id instead (#1795) --- .../backends/hosted_neptune_backend.py | 23 ------------------- .../internal/backends/neptune_backend.py | 23 ------------------- .../internal/backends/neptune_backend_mock.py | 19 --------------- src/neptune/objects/model.py | 9 -------- src/neptune/objects/model_version.py | 10 -------- src/neptune/objects/neptune_object.py | 14 +++++------ src/neptune/objects/project.py | 8 ------- src/neptune/objects/run.py | 9 -------- 8 files changed, 6 insertions(+), 109 deletions(-) diff --git a/src/neptune/internal/backends/hosted_neptune_backend.py b/src/neptune/internal/backends/hosted_neptune_backend.py index 06a819d0d..d5e0cd089 100644 --- a/src/neptune/internal/backends/hosted_neptune_backend.py +++ b/src/neptune/internal/backends/hosted_neptune_backend.py @@ -1133,29 +1133,6 @@ def search_leaderboard_entries( except HTTPNotFound: raise ProjectNotFound(project_id) - def get_run_url(self, run_id: str, workspace: str, project_name: str, sys_id: str) -> str: - base_url = self.get_display_address() - return f"{base_url}/{workspace}/{project_name}/e/{sys_id}" - - def get_project_url(self, project_id: str, workspace: str, project_name: str) -> str: - base_url = self.get_display_address() - return f"{base_url}/{workspace}/{project_name}/" - - def get_model_url(self, model_id: str, workspace: str, project_name: str, sys_id: str) -> str: - base_url = self.get_display_address() - return f"{base_url}/{workspace}/{project_name}/m/{sys_id}" - - def get_model_version_url( - self, - model_version_id: str, - model_id: str, - workspace: str, - project_name: str, - sys_id: str, - ) -> str: - base_url = self.get_display_address() - return f"{base_url}/{workspace}/{project_name}/m/{model_id}/v/{sys_id}" - def query_fields_definitions_within_project( self, project_id: QualifiedName, diff --git a/src/neptune/internal/backends/neptune_backend.py b/src/neptune/internal/backends/neptune_backend.py index 1d8377383..8f62660b4 100644 --- a/src/neptune/internal/backends/neptune_backend.py +++ b/src/neptune/internal/backends/neptune_backend.py @@ -271,29 +271,6 @@ def get_float_series_values( use_proto: Optional[bool] = None, ) -> FloatSeriesValues: ... - @abc.abstractmethod - def get_run_url(self, run_id: str, workspace: str, project_name: str, sys_id: str) -> str: - pass - - @abc.abstractmethod - def get_project_url(self, project_id: str, workspace: str, project_name: str) -> str: - pass - - @abc.abstractmethod - def get_model_url(self, model_id: str, workspace: str, project_name: str, sys_id: str) -> str: - pass - - @abc.abstractmethod - def get_model_version_url( - self, - model_version_id: str, - model_id: str, - workspace: str, - project_name: str, - sys_id: str, - ) -> str: - pass - # WARN: Used in Neptune Fetcher @abc.abstractmethod def get_fields_definitions( diff --git a/src/neptune/internal/backends/neptune_backend_mock.py b/src/neptune/internal/backends/neptune_backend_mock.py index ebe2a845e..db4205c1f 100644 --- a/src/neptune/internal/backends/neptune_backend_mock.py +++ b/src/neptune/internal/backends/neptune_backend_mock.py @@ -497,25 +497,6 @@ def download_file_series_by_index( ): """Non relevant for backend""" - def get_run_url(self, run_id: str, workspace: str, project_name: str, sys_id: str) -> str: - return f"offline/{run_id}" - - def get_project_url(self, project_id: str, workspace: str, project_name: str) -> str: - return f"offline/{project_id}" - - def get_model_url(self, model_id: str, workspace: str, project_name: str, sys_id: str) -> str: - return f"offline/{model_id}" - - def get_model_version_url( - self, - model_version_id: str, - model_id: str, - workspace: str, - project_name: str, - sys_id: str, - ) -> str: - return f"offline/{model_version_id}" - def get_fields_definitions( self, container_id: str, diff --git a/src/neptune/objects/model.py b/src/neptune/objects/model.py index bcd7fd4b2..450a6196f 100644 --- a/src/neptune/objects/model.py +++ b/src/neptune/objects/model.py @@ -259,15 +259,6 @@ def _raise_if_stopped(self): if self._state == ContainerState.STOPPED: raise InactiveModelException(label=self._sys_id) - def get_url(self) -> str: - """Returns the URL that can be accessed within the browser""" - return self._backend.get_model_url( - model_id=self._id, - workspace=self._workspace, - project_name=self._project_name, - sys_id=self._sys_id, - ) - def fetch_model_versions_table( self, *, diff --git a/src/neptune/objects/model_version.py b/src/neptune/objects/model_version.py index 442cfef51..564671fa7 100644 --- a/src/neptune/objects/model_version.py +++ b/src/neptune/objects/model_version.py @@ -250,16 +250,6 @@ def _raise_if_stopped(self): if self._state == ContainerState.STOPPED: raise InactiveModelVersionException(label=self._sys_id) - def get_url(self) -> str: - """Returns the URL that can be accessed within the browser""" - return self._backend.get_model_version_url( - model_version_id=self._id, - workspace=self._workspace, - project_name=self._project_name, - sys_id=self._sys_id, - model_id=self["sys/model_id"].fetch(), - ) - def change_stage(self, stage: str) -> None: """Changes the stage of the model version. diff --git a/src/neptune/objects/neptune_object.py b/src/neptune/objects/neptune_object.py index 928a92019..ef6f7d5d1 100644 --- a/src/neptune/objects/neptune_object.py +++ b/src/neptune/objects/neptune_object.py @@ -51,7 +51,10 @@ NEPTUNE_ENABLE_DEFAULT_ASYNC_LAG_CALLBACK, NEPTUNE_ENABLE_DEFAULT_ASYNC_NO_PROGRESS_CALLBACK, ) -from neptune.exceptions import MetadataInconsistency +from neptune.exceptions import ( + MetadataInconsistency, + NeptuneUnsupportedFunctionalityException, +) from neptune.handler import Handler from neptune.internal.backends.api_model import ( ApiExperiment, @@ -453,10 +456,6 @@ def stop(self, *, seconds: Optional[Union[float, int]] = None) -> None: sec_left = None if seconds is None else seconds - (time.time() - ts) self._op_processor.stop(sec_left) - - if self._mode not in {Mode.OFFLINE, Mode.DEBUG}: - metadata_url = self.get_url().rstrip("/") + "/metadata" - self._logger.info(f"Explore the metadata in the Neptune app: {metadata_url}") self._backend.close() with self._forking_cond: @@ -636,7 +635,6 @@ def _define_attribute(self, _path: List[str], _type: FieldType): def _get_root_handler(self): return Handler(self, "") - @abc.abstractmethod def get_url(self) -> str: """Returns a link to the object in the Neptune app. @@ -644,11 +642,11 @@ def get_url(self) -> str: API reference: https://docs.neptune.ai/api/universal/#get_url """ - ... + raise NeptuneUnsupportedFunctionalityException def _startup(self, debug_mode): if not debug_mode: - self._logger.info(f"Neptune initialized. Open in the app: {self.get_url()}") + self._logger.info(f"Neptune initialized. Object identifier: {self._id}") self.start() diff --git a/src/neptune/objects/project.py b/src/neptune/objects/project.py index d6efdd924..b322a2cb7 100644 --- a/src/neptune/objects/project.py +++ b/src/neptune/objects/project.py @@ -190,14 +190,6 @@ def _raise_if_stopped(self): if self._state == ContainerState.STOPPED: raise InactiveProjectException(label=f"{self._workspace}/{self._project_name}") - def get_url(self) -> str: - """Returns the URL that can be accessed within the browser""" - return self._backend.get_project_url( - project_id=self._id, - workspace=self._workspace, - project_name=self._project_name, - ) - def fetch_runs_table( self, *, diff --git a/src/neptune/objects/run.py b/src/neptune/objects/run.py index d875ad0c3..9fa2c5fee 100644 --- a/src/neptune/objects/run.py +++ b/src/neptune/objects/run.py @@ -544,15 +544,6 @@ def _raise_if_stopped(self): if self._state == ContainerState.STOPPED: raise InactiveRunException(label=self._sys_id) - def get_url(self) -> str: - """Returns the URL that can be accessed within the browser""" - return self._backend.get_run_url( - run_id=self._id, - workspace=self._workspace, - project_name=self._project_name, - sys_id=self._sys_id, - ) - def capture_only_if_non_interactive(mode) -> bool: if in_interactive() or in_notebook():