Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f5d1d4e
feat(entities): add grouped entity counts
callingmedic911 Jul 21, 2026
8487614
feat(entities): expose grouped counts in list API
callingmedic911 Jul 21, 2026
0cc8171
feat(entities): add client count helper
callingmedic911 Jul 21, 2026
b525430
refactor(entities): simplify grouped count implementation
callingmedic911 Jul 21, 2026
941a3b1
chore(openapi): refresh entity grouped counts contract
callingmedic911 Jul 21, 2026
5ad127f
fix(entities): harden grouped count results
callingmedic911 Jul 21, 2026
64ed8ca
fix(entities): validate grouped count fields
callingmedic911 Jul 21, 2026
3f470bb
fix(entities): preserve null string group keys
callingmedic911 Jul 21, 2026
91b9d12
docs: narrow entity grouped count design
callingmedic911 Jul 22, 2026
22da54b
refactor(entities): narrow grouped counts
callingmedic911 Jul 22, 2026
58ea3a0
fix(entities): validate empty count field
callingmedic911 Jul 22, 2026
963263a
refactor(entities): narrow grouped count client
callingmedic911 Jul 22, 2026
0ac25e4
chore(entities): finalize narrow grouped counts
callingmedic911 Jul 22, 2026
c185259
chore(entities): apply final-review cleanup to grouped counts
callingmedic911 Jul 22, 2026
76d03e6
feat(studio): add Insights section with experiment↔insight linking
rrhyne Jul 17, 2026
7834130
don't change status on open
rrhyne Jul 20, 2026
e4e3e72
fix(studio): align Insights UI with platform contracts
callingmedic911 Jul 21, 2026
ed458bd
refactor(insights): use grouped entity counts
callingmedic911 Jul 23, 2026
c78e4d0
refactor(studio): trim optimizer flag plumbing
callingmedic911 Jul 23, 2026
1cfc446
feat(insights): show trace last-seen time
callingmedic911 Jul 23, 2026
125af08
fix(insights): normalize testbed experiment metadata
ryana Jul 22, 2026
d562ee4
feat(insights): add Eval Author run results
ryana Jul 23, 2026
6c09999
fix(studio): label Eval Author run statuses
ryana Jul 23, 2026
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
24 changes: 22 additions & 2 deletions openapi/ga/individual/platform.openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions openapi/ga/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions openapi/openapi.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ async def list(
page: int = 1,
page_size: int = 100,
) -> ListResponse[EntityT]: ...
async def count_by(
self,
entity_type: EntityTypeLike,
field: str,
*,
workspace: str = DEFAULT_WORKSPACE,
filter_obj: dict[str, Any] | None = None,
) -> dict[str, int]: ...
async def get(self, entity_type: EntityTypeLike, name: str, *, workspace: Optional[str] = None) -> EntityT: ...
async def get_by_id(self, entity_type: EntityTypeLike, entity_id: str) -> EntityT: ...
async def update(self, entity: EntityT, *, original_name: str | None = None) -> EntityT: ...
Expand Down Expand Up @@ -493,6 +501,34 @@ async def list(

return ListResponse(data=entities, pagination=pagination)

async def count_by(
self,
entity_type: EntityTypeLike,
field: str,
*,
workspace: str = DEFAULT_WORKSPACE,
filter_obj: dict[str, Any] | None = None,
) -> dict[str, int]:
"""Return the number of matching entities grouped by ``field``."""
if not field.isidentifier():
raise ValueError(f"Field '{field}' is not a direct entity data field")

filter_dict = _convert_filter_obj_to_filter_str(filter_obj) if filter_obj else {}
effective_filter = json.dumps(filter_dict) if filter_dict else omit

response = await self.entities_api.list(
_get_entity_type(entity_type),
workspace=workspace,
filter=effective_filter,
page=1,
page_size=1,
extra_query={"count_by": f"data.{field}"},
)
group_counts = getattr(response, "group_counts", None)
if group_counts is None:
raise EntityStoreError("Grouped counts not found in response")
return TypeAdapter(dict[str, int]).validate_python(group_counts)

async def create(self, entity: EntityT) -> EntityT:
"""Create a new entity.

Expand Down
62 changes: 62 additions & 0 deletions packages/nemo_platform_plugin/tests/test_entity_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

from unittest.mock import AsyncMock, Mock

import pytest
from nemo_platform.types.entities import EntitiesPage
from nemo_platform.types.shared.pagination_data import PaginationData
from nemo_platform_plugin.entities import EntityClient, EntityStoreError


class ExperimentGroup:
__entity_type__ = "experiment_group"


def _entities_page(group_counts: dict[str, int] | None = None) -> EntitiesPage:
return EntitiesPage.model_construct(
data=[],
pagination=PaginationData(page=1, page_size=1, current_page_size=0, total_pages=0, total_results=0),
group_counts=group_counts,
)


@pytest.mark.asyncio
async def test_count_by_returns_grouped_counts_for_shorthand_filter() -> None:
mock_api = Mock()
mock_api.list = AsyncMock(return_value=_entities_page(group_counts={"insight-a": 2}))
client = EntityClient(mock_api)

counts = await client.count_by(
ExperimentGroup,
"insight_id",
filter_obj={
"insight_id": {"$in": ["insight-a"]},
"is_deleted": False,
},
)

assert counts == {"insight-a": 2}
assert mock_api.list.await_args.kwargs["filter"] == (
'{"data.insight_id": {"$in": ["insight-a"]}, "data.is_deleted": false}'
)
assert mock_api.list.await_args.kwargs["extra_query"] == {"count_by": "data.insight_id"}


@pytest.mark.asyncio
async def test_count_by_rejects_response_without_grouped_counts() -> None:
mock_api = Mock()
mock_api.list = AsyncMock(return_value=_entities_page())
client = EntityClient(mock_api)

with pytest.raises(EntityStoreError, match="Grouped counts not found"):
await client.count_by(ExperimentGroup, "insight_id")


@pytest.mark.asyncio
async def test_count_by_rejects_non_direct_field() -> None:
mock_api = Mock()
client = EntityClient(mock_api)

with pytest.raises(ValueError, match="direct entity data field"):
await client.count_by(ExperimentGroup, "data.insight_id")
Loading