Skip to content

Commit 6ea4f1f

Browse files
Apply suggestions from code review
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 17f8b0d commit 6ea4f1f

4 files changed

Lines changed: 14 additions & 23 deletions

File tree

specifications/SPEC_PLATFORM_SERVICE.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,6 @@ class ApplicationRun(_AuthenticatedResource):
559559
Returns:
560560
The created AccessGrant.
561561
"""
562-
Returns:
563-
The created AccessGrant.
564-
"""
565562
566563
def list_share_grants(
567564
self,
@@ -583,15 +580,6 @@ class ApplicationRun(_AuthenticatedResource):
583580
Returns:
584581
Iterator of AccessGrant objects for this run.
585582
"""
586-
"""Lists all active access grants on this run.
587-
588-
Args:
589-
subject_type: Optional filter by subject type.
590-
subject_id: Optional filter by subject identifier.
591-
592-
Returns:
593-
Iterator of AccessGrant objects for this run.
594-
"""
595583
```
596584
597585
```python

src/aignostics/application/_cli.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,7 @@ def run_share_token_list(
14361436
tokens = list(Service().application_run_share_tokens(run_id))
14371437

14381438
if format == "json":
1439-
print(json.dumps([t.model_dump() for t in tokens], indent=2, default=str))
1439+
print(json.dumps([t.model_dump(mode="json") for t in tokens], indent=2))
14401440
else:
14411441
if not tokens:
14421442
console.print("No active share tokens.")
@@ -1481,7 +1481,7 @@ def run_share_token_create(
14811481
try:
14821482
token = Service().application_run_create_share_token(run_id, expires_at=expires_at_dt)
14831483
if format == "json":
1484-
print(json.dumps(token.model_dump(), indent=2, default=str))
1484+
print(json.dumps(token.model_dump(mode="json"), indent=2))
14851485
else:
14861486
expires = token.expires_at.isoformat() if token.expires_at else "never"
14871487
console.print(f"Share token created for run '{run_id}'.")

src/aignostics/application/_service.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
ApplicationVersion,
2626
Client,
2727
ForbiddenException,
28+
ForbiddenException,
2829
InputArtifact,
2930
InputItem,
3031
NotFoundException,
@@ -33,6 +34,7 @@
3334
RunOutput,
3435
RunState,
3536
)
37+
from aignostics.platform.resources.access import AccessGrant, ShareToken
3638
from aignostics.platform import Service as PlatformService
3739
from aignostics.platform.resources.access import AccessGrant, ShareToken
3840
from aignostics.utils import BaseService, Health, sanitize_path_component
@@ -1384,18 +1386,18 @@ def application_run_share_tokens(
13841386
try:
13851387
client = self._get_platform_client()
13861388
run = client.run(run_id)
1387-
seen: set[str] = set()
1388-
for grant in run.list_share_grants(
1389+
1390+
tokens = self._get_platform_client().share_tokens.list(run_id=run_id, page_size=page_size)
1391+
token_grants = set(g.subject_id for g in run.list_share_grants(
13891392
subject_type=SubjectType.SHARE_TOKEN,
13901393
page_size=page_size,
13911394
nocache=True,
1392-
):
1393-
token_id = grant.subject_id
1394-
if token_id not in seen:
1395-
seen.add(token_id)
1396-
share_token = ShareToken.for_token_id(token_id)
1397-
if not share_token.revoked:
1398-
yield share_token
1395+
))
1396+
1397+
for token in tokens:
1398+
if token.share_token_id in token_grants:
1399+
yield token
1400+
13991401
except NotFoundException as e:
14001402
message = f"Application run with ID '{run_id}' not found: {e}"
14011403
logger.warning(message)

src/aignostics/platform/resources/runs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,7 @@ def fetch_grant_page(cached_run_id: str, **kwargs: object) -> list[GrantReadResp
721721
lambda **kw: fetch_grant_page(
722722
run_id,
723723
nocache=nocache,
724+
_cache_run_id=self.run_id,
724725
subject_type=subject_type,
725726
subject_id=subject_id,
726727
relation=relation,

0 commit comments

Comments
 (0)