Skip to content

Commit

Permalink
Print metadata url on stop (#883)
Browse files Browse the repository at this point in the history
* store running mode in metadata container

* print metadata url on stop
  • Loading branch information
pkasprzyk authored Apr 14, 2022
1 parent dba09de commit a4efc64
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions neptune/new/internal/init/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def init_model(

_model = Model(
id_=api_model.id,
mode=mode,
backend=backend,
op_processor=operation_processor,
background_job=BackgroundJobList(background_jobs),
Expand Down
1 change: 1 addition & 0 deletions neptune/new/internal/init/model_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def init_model_version(

_model_version = ModelVersion(
id_=api_model_version.id,
mode=mode,
backend=backend,
op_processor=operation_processor,
background_job=BackgroundJobList(background_jobs),
Expand Down
1 change: 1 addition & 0 deletions neptune/new/internal/init/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def init_project(

project = Project(
id_=project_obj.id,
mode=mode,
backend=backend,
op_processor=operation_processor,
background_job=BackgroundJobList(background_jobs),
Expand Down
1 change: 1 addition & 0 deletions neptune/new/internal/init/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def init_run(

_run = Run(
id_=api_run.id,
mode=mode,
backend=backend,
op_processor=operation_processor,
background_job=BackgroundJobList(background_jobs),
Expand Down
11 changes: 11 additions & 0 deletions neptune/new/metadata_containers/metadata_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
from neptune.new.types.atoms.datetime import Datetime
from neptune.new.types.atoms.float import Float
from neptune.new.types.atoms.string import String
from neptune.new.types.mode import Mode
from neptune.new.types.namespace import Namespace
from neptune.new.types.value import Value
from neptune.new.types.value_copy import ValueCopy
Expand Down Expand Up @@ -107,6 +108,7 @@ def __init__(
self,
*,
id_: UniqueId,
mode: Mode,
backend: NeptuneBackend,
op_processor: OperationProcessor,
background_job: BackgroundJob,
Expand All @@ -117,6 +119,7 @@ def __init__(
sys_id: SysId,
):
self._id = id_
self._mode = mode
self._project_id = project_id
self._project_name = project_name
self._workspace = workspace
Expand Down Expand Up @@ -157,6 +160,11 @@ def _docs_url_stop(self) -> str:
def _url(self) -> str:
raise NotImplementedError

@property
@abc.abstractmethod
def _metadata_url(self) -> str:
raise NotImplementedError

def _get_subpath_suggestions(
self, path_prefix: str = None, limit: int = 1000
) -> List[str]:
Expand Down Expand Up @@ -211,6 +219,9 @@ def stop(self, seconds: Optional[Union[float, int]] = None) -> None:
with self._lock:
sec_left = None if seconds is None else seconds - (time.time() - ts)
self._op_processor.stop(sec_left)
if self._mode != Mode.OFFLINE:
click.echo("Explore the metadata in Neptune UI:")
click.echo(self._metadata_url)
self._backend.close()
self._state = ContainerState.STOPPED

Expand Down
4 changes: 4 additions & 0 deletions neptune/new/metadata_containers/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def _url(self) -> str:
sys_id=self._sys_id,
)

@property
def _metadata_url(self) -> str:
return self._url.rstrip("/") + "/metadata"

def fetch_model_versions_table(self) -> Table:
"""Retrieve all model versions of the given model.
Expand Down
4 changes: 4 additions & 0 deletions neptune/new/metadata_containers/model_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def _url(self) -> str:
model_id=self["sys/model_id"].fetch(),
)

@property
def _metadata_url(self) -> str:
return self._url.rstrip("/") + "/metadata"

def change_stage(self, stage: str):
mapped_stage = ModelVersionStage(stage)

Expand Down
7 changes: 7 additions & 0 deletions neptune/new/metadata_containers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from neptune.new.internal.utils import as_list
from neptune.new.metadata_containers import MetadataContainer
from neptune.new.metadata_containers.metadata_containers_table import Table
from neptune.new.types.mode import Mode


class Project(MetadataContainer):
Expand All @@ -50,6 +51,7 @@ def __init__(
self,
*,
id_: UniqueId,
mode: Mode,
backend: NeptuneBackend,
op_processor: OperationProcessor,
background_job: BackgroundJob,
Expand All @@ -60,6 +62,7 @@ def __init__(
):
super().__init__(
id_=id_,
mode=mode,
backend=backend,
op_processor=op_processor,
background_job=background_job,
Expand All @@ -86,6 +89,10 @@ def _url(self) -> str:
project_name=self._project_name,
)

@property
def _metadata_url(self) -> str:
return self._url.rstrip("/") + "/metadata"

# pylint:disable=redefined-builtin
def fetch_runs_table(
self,
Expand Down
7 changes: 7 additions & 0 deletions neptune/new/metadata_containers/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
OperationProcessor,
)
from neptune.new.metadata_containers import MetadataContainer
from neptune.new.types.mode import Mode


class Run(MetadataContainer):
Expand Down Expand Up @@ -99,6 +100,7 @@ def __init__(
self,
*,
id_: UniqueId,
mode: Mode,
backend: NeptuneBackend,
op_processor: OperationProcessor,
background_job: BackgroundJob,
Expand All @@ -111,6 +113,7 @@ def __init__(
):
super().__init__(
id_=id_,
mode=mode,
backend=backend,
op_processor=op_processor,
background_job=background_job,
Expand Down Expand Up @@ -145,6 +148,10 @@ def _url(self) -> str:
sys_id=self._sys_id,
)

@property
def _metadata_url(self) -> str:
return self._url

@property
def _short_id(self) -> str:
return self._sys_id
Expand Down
2 changes: 2 additions & 0 deletions tests/neptune/new/attributes/test_attribute_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
SyncOperationProcessor,
)
from neptune.new.metadata_containers import Run
from neptune.new.types.mode import Mode

_now = time.time()

Expand All @@ -46,6 +47,7 @@ def _create_run(processor: Optional[OperationProcessor] = None):
processor = SyncOperationProcessor(exp.id, ContainerType.RUN, backend)
_run = Run(
id_=exp.id,
mode=Mode.SYNC,
backend=backend,
op_processor=processor,
background_job=MagicMock(),
Expand Down

0 comments on commit a4efc64

Please sign in to comment.