Skip to content

Add neptune_scale.legacy.Run #107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions src/neptune_scale/api/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@
from neptune_api.proto.neptune_pb.ingest.v1.common_pb2 import Run as CreateRun
from neptune_api.proto.neptune_pb.ingest.v1.pub.ingest_pb2 import RunOperation

from neptune_scale.api.attribute import (
Attribute,
AttributeStore,
)
from neptune_scale.api.attribute import AttributeStore
from neptune_scale.api.validation import (
verify_dict_type,
verify_max_length,
Expand Down Expand Up @@ -390,12 +387,6 @@ def _create_run(
)
self._operations_queue.enqueue(operation=operation)

def __getitem__(self, key: str) -> Attribute:
return self._attr_store[key]

def __setitem__(self, key: str, value: Any) -> None:
self._attr_store[key] = value

def log_metrics(
self,
data: dict[str, Union[float, int]],
Expand Down
28 changes: 28 additions & 0 deletions src/neptune_scale/legacy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from typing import Any

import neptune_scale.api.run
from neptune_scale.api.attribute import Attribute

__all__ = ("Run",)


class Run(neptune_scale.api.run.Run):
"""This class extends the main Run class with a dict-like API compatible (on a basic level)
with the legacy neptune-client package.

Example:

from neptune_scale.legacy import Run

run = Run(...)
run['foo'] = 1
run['metrics/loss'].append(0.5, step=10)

run.close()
"""

def __getitem__(self, key: str) -> Attribute:
return self._attr_store[key]

def __setitem__(self, key: str, value: Any) -> None:
self._attr_store[key] = value
2 changes: 1 addition & 1 deletion tests/unit/test_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
mark,
)

from neptune_scale import Run
from neptune_scale.api.attribute import cleanup_path
from neptune_scale.legacy import Run


@fixture
Expand Down
Loading