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

Introduce filtering columns when fetching tables #986

Merged
merged 6 commits into from
Sep 5, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add tests
  • Loading branch information
shnela committed Aug 30, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6bfcc3b1e2b26526951c845e36c4095e29ebd6b8
16 changes: 14 additions & 2 deletions tests/neptune/new/client/abstract_tables_test.py
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import uuid
from abc import abstractmethod
from datetime import datetime
from typing import List

from mock import Mock, patch

@@ -32,6 +33,7 @@
LeaderboardEntry,
)
from neptune.new.internal.backends.neptune_backend_mock import NeptuneBackendMock
from neptune.new.metadata_containers.metadata_containers_table import Table, TableEntry


@patch(
@@ -43,11 +45,11 @@ class AbstractTablesTestMixin:
expected_container_type = None

@abstractmethod
def get_table(self):
def get_table(self, **kwargs) -> Table:
pass

@abstractmethod
def get_table_entries(self, table):
def get_table_entries(self, table) -> List[TableEntry]:
pass

@classmethod
@@ -95,6 +97,16 @@ def build_attributes_leaderboard(now: datetime):
attributes.append(AttributeWithProperties("image/series", AttributeType.IMAGE_SERIES, None))
return attributes

@patch.object(NeptuneBackendMock, "search_leaderboard_entries")
def test_get_table_with_columns_filter(self, search_leaderboard_entries):
# when
self.get_table(columns=["datetime"])

# then
self.assertEqual(1, search_leaderboard_entries.call_count)
parameters = search_leaderboard_entries.call_args[1]
self.assertEqual({"sys/id", "datetime"}, parameters.get("columns"))

@patch.object(NeptuneBackendMock, "search_leaderboard_entries")
def test_get_table_as_pandas(self, search_leaderboard_entries):
# given
8 changes: 5 additions & 3 deletions tests/neptune/new/client/test_model_tables.py
Original file line number Diff line number Diff line change
@@ -15,17 +15,19 @@
#

import unittest
from typing import List

from neptune.new import get_project
from neptune.new.internal.container_type import ContainerType
from neptune.new.metadata_containers.metadata_containers_table import Table, TableEntry
from tests.neptune.new.client.abstract_tables_test import AbstractTablesTestMixin


class TestModelTables(AbstractTablesTestMixin, unittest.TestCase):
expected_container_type = ContainerType.MODEL

def get_table(self):
return get_project("organization/project").fetch_models_table()
def get_table(self, **kwargs) -> Table:
return get_project("organization/project").fetch_models_table(**kwargs)

def get_table_entries(self, table):
def get_table_entries(self, table) -> List[TableEntry]:
return table.to_rows()
8 changes: 5 additions & 3 deletions tests/neptune/new/client/test_model_version_tables.py
Original file line number Diff line number Diff line change
@@ -15,21 +15,23 @@
#

import unittest
from typing import List

from neptune.new import init_model
from neptune.new.internal.container_type import ContainerType
from neptune.new.metadata_containers.metadata_containers_table import Table, TableEntry
from tests.neptune.new.client.abstract_tables_test import AbstractTablesTestMixin


class TestModelVersionTables(AbstractTablesTestMixin, unittest.TestCase):
expected_container_type = ContainerType.MODEL_VERSION

def get_table(self):
def get_table(self, **kwargs) -> Table:
return init_model(
model="organization/project",
project="PRO-MOD",
mode="read-only",
).fetch_model_versions_table()
).fetch_model_versions_table(**kwargs)

def get_table_entries(self, table):
def get_table_entries(self, table) -> List[TableEntry]:
return table.to_rows()
8 changes: 5 additions & 3 deletions tests/neptune/new/client/test_run_tables.py
Original file line number Diff line number Diff line change
@@ -15,17 +15,19 @@
#

import unittest
from typing import List

from neptune.new import get_project
from neptune.new.internal.container_type import ContainerType
from neptune.new.metadata_containers.metadata_containers_table import Table, TableEntry
from tests.neptune.new.client.abstract_tables_test import AbstractTablesTestMixin


class TestRunTables(AbstractTablesTestMixin, unittest.TestCase):
expected_container_type = ContainerType.RUN

def get_table(self):
return get_project("organization/project").fetch_runs_table()
def get_table(self, **kwargs) -> Table:
return get_project("organization/project").fetch_runs_table(**kwargs)

def get_table_entries(self, table):
def get_table_entries(self, table) -> List[TableEntry]:
return table.to_rows()