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

[Patch] Filter summaries clientside in get_or_create #2200

Merged
merged 1 commit into from Apr 21, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 11 additions & 7 deletions client/verta/verta/operations/monitoring/summaries.py
Expand Up @@ -8,7 +8,7 @@

from verta._internal_utils._utils import as_list_of_str
from verta._internal_utils import pagination_utils, time_utils
from .utils import extract_ids, maybe
from .utils import extract_ids, extract_id, maybe
from verta._protos.public.monitoring import Summary_pb2 as SummaryService
from verta._protos.public.monitoring.Summary_pb2 import (
CreateSummaryRequest,
Expand Down Expand Up @@ -350,12 +350,16 @@ def get_or_create(self, name, data_type_cls, monitored_entity):
)
query = SummaryQuery(names=[name], monitored_entities=[monitored_entity])
retrieved = self.find(query)
if retrieved and len(retrieved) > 1:
warnings.warn(
"found multiple summaries with name: {}, for monitored entity: {}".format(
name, monitored_entity
)
)
# if retrieved and len(retrieved) > 1:
# warnings.warn(
# "found multiple summaries with name: {}, for monitored entity: {}".format(
# name, monitored_entity
# )
# )
if retrieved:
monitored_entity_id = extract_id(monitored_entity)
cond = lambda s: s.name == name and s.monitored_entity_id == monitored_entity_id
retrieved = list(filter(cond, retrieved))
if retrieved:
summary = retrieved[0]
else:
Expand Down