Skip to content

Commit

Permalink
Get rid of printing URL and use custom id instead (#1795)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raalsky authored May 27, 2024
1 parent 79af6dc commit 7b2f7a4
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 109 deletions.
23 changes: 0 additions & 23 deletions src/neptune/internal/backends/hosted_neptune_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 0 additions & 23 deletions src/neptune/internal/backends/neptune_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 0 additions & 19 deletions src/neptune/internal/backends/neptune_backend_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 0 additions & 9 deletions src/neptune/objects/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*,
Expand Down
10 changes: 0 additions & 10 deletions src/neptune/objects/model_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 6 additions & 8 deletions src/neptune/objects/neptune_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -636,19 +635,18 @@ 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.
The same link is printed in the console once the object has been initialized.
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()

Expand Down
8 changes: 0 additions & 8 deletions src/neptune/objects/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*,
Expand Down
9 changes: 0 additions & 9 deletions src/neptune/objects/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 7b2f7a4

Please sign in to comment.