Skip to content
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

Added SupportsNamespaces interface #1280

Merged
merged 6 commits into from
Mar 9, 2023
Merged

Added SupportsNamespaces interface #1280

merged 6 commits into from
Mar 9, 2023

Conversation

Raalsky
Copy link
Contributor

@Raalsky Raalsky commented Mar 1, 2023

from neptune.typing import SupportsNamespaces
from neptune import Run


class NeptuneCallback:
    def __init__(self, start_from: SupportsNamespaces):
        self._start_from = start_from

    def log_accuracy(self, accuracy: float) -> None:
        self._start_from["train/acc"] = accuracy


if __name__ == '__main__':
    with Run() as run:
        callback = NeptuneCallback(start_from=run)
        callback.log_accuracy(0.8)

    with Run() as run:
        callback = NeptuneCallback(start_from=run["some/random/path"])
        callback.log_accuracy(0.8)

Before submitting checklist

  • Did you update the CHANGELOG? (not for test updates, internal changes/refactors or CI/CD setup)
  • Did you asked the docs owner to review all the updated user-facing interfaces?

@codecov
Copy link

codecov bot commented Mar 1, 2023

Codecov Report

Patch coverage has no change and project coverage change: -71.27 ⚠️

Comparison is base (e0da79e) 71.26% compared to head (5be21c7) 0.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #1280       +/-   ##
==========================================
- Coverage   71.26%   0.00%   -71.27%     
==========================================
  Files         277     279        +2     
  Lines       13586   13610       +24     
==========================================
- Hits         9682       0     -9682     
- Misses       3904   13610     +9706     
Flag Coverage Δ
e2e ?
unit ?
unit-pull-request 0.00% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/neptune/handler.py 0.00% <0.00%> (-82.45%) ⬇️
src/neptune/metadata_containers/abstract.py 0.00% <0.00%> (ø)
.../neptune/metadata_containers/metadata_container.py 0.00% <0.00%> (-88.48%) ⬇️
src/neptune/typing.py 0.00% <0.00%> (ø)
src/neptune/envs.py 0.00% <0.00%> (-100.00%) ⬇️
src/neptune/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
src/neptune/constants.py 0.00% <0.00%> (-100.00%) ⬇️
src/neptune/common/envs.py 0.00% <0.00%> (-100.00%) ⬇️
src/neptune/legacy/envs.py 0.00% <0.00%> (-100.00%) ⬇️
src/neptune/cli/__init__.py 0.00% <0.00%> (-100.00%) ⬇️
... and 234 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Raalsky Raalsky force-pushed the rj/neptune-typing branch from ee82a81 to 3209399 Compare March 7, 2023 16:41
@Raalsky Raalsky changed the title Draft: Added Assignable interface Added SupportsNamespaces Mar 7, 2023
@Raalsky Raalsky changed the title Added SupportsNamespaces Added SupportsNamespaces interface Mar 7, 2023

@abstractmethod
def __delitem__(self, path) -> None:
...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add get_root_object to the interface? + to Run as something like

def get_root_object(self):
   return self

This is something we use in many integrations and having it as a part of interface would help to avoid unnecessary type checks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you wish. Done

@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__all__ = ["expect_not_an_experiment", "join_paths", "verify_type", "RunType"]
__all__ = ["expect_not_an_experiment", "join_paths", "verify_type", "RunType", "SupportsNamespaces"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want it to be importable from neptune.integration.utils? Why not just use neptune.metadata_containers.abstract ? Even if we want to keep the neptune.metadata_containers.abstract private, maybe it'd make sense to have it in some kind of "types" or "interfaces" module, it's not something I'll look for in integration.utils.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I've exposed it via neptune.typing. What do you think?

twolodzko
twolodzko previously approved these changes Mar 8, 2023
Copy link
Contributor

@twolodzko twolodzko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it, but left few small comments on possible improvements.

Copy link
Contributor

@twolodzko twolodzko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Raalsky Raalsky merged commit eaa0044 into master Mar 9, 2023
@Raalsky Raalsky deleted the rj/neptune-typing branch March 9, 2023 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants