Skip to content

feat: Share runs via Python SDK#667

Open
dima-aignostics wants to merge 34 commits into
mainfrom
feat/PYSDK-132-add-run-sharing-to-python-sdk
Open

feat: Share runs via Python SDK#667
dima-aignostics wants to merge 34 commits into
mainfrom
feat/PYSDK-132-add-run-sharing-to-python-sdk

Conversation

@dima-aignostics

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings June 4, 2026 11:10
@dima-aignostics dima-aignostics requested a review from a team as a code owner June 4, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to add “run sharing” capabilities to the Python SDK by introducing access-control resource wrappers (grants + share tokens), wiring them into the platform client, and exposing sharing workflows through the application service and CLI.

Changes:

  • Added new access-control resource layer (AccessGrant, ShareToken, ShareTokens) and new Run helpers (list_share_grants, grant_access).
  • Added new application service + CLI commands under run share ... to list/grant/revoke access and manage share tokens.
  • Regenerated codegen artifacts/docs for updated API parameters (e.g., grants relation filter, additional run filters, run organization_id field).

Reviewed changes

Copilot reviewed 8 out of 61 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
src/aignostics/platform/resources/access.py New access-control resource models and share-token listing/creation logic.
src/aignostics/platform/resources/runs.py Adds run-level grant listing/creation helpers with caching/retry integration.
src/aignostics/platform/_client.py Exposes a share_tokens resource on Client.
src/aignostics/application/_service.py Adds service methods for run sharing and token management.
src/aignostics/application/_cli.py Adds run share ... CLI command group.
tests/aignostics/platform/resources/access_test.py Unit tests for access resources.
tests/aignostics/platform/resources/run_sharing_test.py Unit tests for run-sharing workflows (currently mismatched with implementation).
codegen/in/openapi.json + codegen/out/** Codegen updates reflecting API spec changes.

Comment thread src/aignostics/platform/resources/access.py
Comment thread src/aignostics/platform/resources/access.py
Comment thread src/aignostics/platform/resources/access.py Outdated
Comment thread src/aignostics/platform/resources/runs.py
Comment thread src/aignostics/platform/resources/runs.py Outdated
Comment thread src/aignostics/platform/_client.py Outdated
Comment thread src/aignostics/platform/resources/access.py Outdated
Comment thread tests/aignostics/platform/resources/run_sharing_test.py
Comment thread tests/aignostics/platform/resources/access_test.py Outdated
Comment thread src/aignostics/platform/resources/runs.py
@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.21549% with 35 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/aignostics/application/_service.py 74.11% 22 Missing ⚠️
src/aignostics/platform/resources/access.py 82.81% 11 Missing ⚠️
src/aignostics/application/_cli.py 98.48% 1 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
src/aignostics/platform/_client.py 93.18% <100.00%> (+0.15%) ⬆️
src/aignostics/platform/resources/runs.py 85.41% <100.00%> (+0.74%) ⬆️
src/aignostics/application/_cli.py 77.79% <98.48%> (+3.99%) ⬆️
src/aignostics/platform/resources/access.py 82.81% <82.81%> (ø)
src/aignostics/application/_service.py 62.50% <74.11%> (+1.53%) ⬆️

... and 8 files with indirect coverage changes

Copilot AI review requested due to automatic review settings June 4, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 61 changed files in this pull request and generated 20 comments.

Comment thread src/aignostics/platform/resources/access.py Outdated
Comment thread src/aignostics/platform/resources/access.py Outdated
Comment thread src/aignostics/platform/resources/runs.py Outdated
Comment thread src/aignostics/platform/resources/runs.py
Comment thread src/aignostics/platform/resources/runs.py Outdated
Comment thread src/aignostics/application/_cli.py
Comment thread tests/aignostics/platform/resources/access_test.py Outdated
Comment thread tests/aignostics/platform/resources/access_test.py Outdated
Comment thread tests/aignostics/platform/resources/access_test.py Outdated
Comment thread tests/aignostics/platform/resources/access_test.py Outdated
Copilot AI review requested due to automatic review settings June 4, 2026 18:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 61 changed files in this pull request and generated 9 comments.

Comment thread src/aignostics/platform/resources/access.py
Comment thread src/aignostics/platform/resources/runs.py
Comment thread src/aignostics/platform/resources/runs.py Outdated
Comment thread src/aignostics/platform/resources/runs.py Outdated
Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/application/_service.py Outdated
Comment thread src/aignostics/application/_cli.py Outdated
Comment thread src/aignostics/platform/resources/access.py
@dima-aignostics dima-aignostics force-pushed the feat/PYSDK-132-add-run-sharing-to-python-sdk branch from 3bbec8d to 1131c91 Compare June 4, 2026 18:53
Copilot AI review requested due to automatic review settings June 4, 2026 18:55
@dima-aignostics dima-aignostics force-pushed the feat/PYSDK-132-add-run-sharing-to-python-sdk branch from 1131c91 to fa0f3b9 Compare June 4, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 63 changed files in this pull request and generated 7 comments.

Comment thread src/aignostics/platform/resources/access.py Outdated
Comment thread src/aignostics/platform/resources/runs.py
Comment thread src/aignostics/platform/resources/runs.py
Comment thread src/aignostics/application/_service.py Outdated
Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/application/_service.py Outdated
Comment thread src/aignostics/application/_cli.py
@dima-aignostics dima-aignostics force-pushed the feat/PYSDK-132-add-run-sharing-to-python-sdk branch from fa0f3b9 to c4e64be Compare June 4, 2026 19:26
Copilot AI review requested due to automatic review settings June 5, 2026 13:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 64 changed files in this pull request and generated 4 comments.

Comment thread src/aignostics/platform/resources/access.py
Comment thread src/aignostics/application/_cli.py
Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/application/_cli.py Outdated
Copilot AI review requested due to automatic review settings June 8, 2026 08:01
@dima-aignostics dima-aignostics force-pushed the feat/PYSDK-132-add-run-sharing-to-python-sdk branch from ffa17dc to ece8b91 Compare June 8, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 66 changed files in this pull request and generated 4 comments.

Comment thread src/aignostics/application/_cli.py
Comment thread src/aignostics/application/_cli.py Outdated
Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/application/_service.py Outdated
Copilot AI review requested due to automatic review settings June 8, 2026 08:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 66 changed files in this pull request and generated 4 comments.

Comment thread src/aignostics/application/_cli.py
Comment thread src/aignostics/platform/resources/access.py
Comment thread src/aignostics/platform/resources/access.py
Comment thread src/aignostics/application/_service.py Outdated
Copilot AI review requested due to automatic review settings June 8, 2026 09:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 66 changed files in this pull request and generated 1 comment.

Comment thread src/aignostics/application/_cli.py
dima-aignostics and others added 2 commits June 9, 2026 12:37
The decorator was accidentally doubled in the code review suggestions commit,
which would register the command twice and break CLI invocation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…f share-status check

ShareTokens.list(run_id=..., revoked=False) filters on the *token's* revoked flag,
not the access grant's. After application_run_revoke_share_token revokes only the
grant (not the token itself), the token still appears in share status, making the
previous step-4 assertion always fail.

Replace the share-status check with a second revoke attempt: the service raises
NotFoundException (→ exit 2) when no active grant is found for the token on the
run, which is the authoritative signal that the grant is gone.

Also ignore run_dont_commit.py in pyrightconfig to keep local lint clean.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 9, 2026 20:15
@dima-aignostics dima-aignostics force-pushed the feat/PYSDK-132-add-run-sharing-to-python-sdk branch from f6b39f5 to e6deccd Compare June 9, 2026 20:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 71 changed files in this pull request and generated 5 comments.

Comment thread specifications/SPEC_PLATFORM_SERVICE.md Outdated
Comment thread specifications/SPEC_PLATFORM_SERVICE.md Outdated
Comment thread src/aignostics/application/_service.py Outdated
Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/application/_service.py
ShareTokens.list(run_id=..., revoked=False) filters on the token's own
revoked flag. After application_run_revoke_share_token revokes the grant
(not the token itself), the token still appeared in share status.

Fix application_run_share_tokens to drive the list from active grants
(Run.list_share_grants(subject_type=SHARE_TOKEN)) and resolve each
grant's subject_id to a full ShareToken. This guarantees that only tokens
with live grants appear in the output.

Also extend the e2e test with a retry-wrapped share-status step that
verifies the token is absent after revocation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 9, 2026 20:22
@dima-aignostics dima-aignostics force-pushed the feat/PYSDK-132-add-run-sharing-to-python-sdk branch from e6deccd to 77e1eb8 Compare June 9, 2026 20:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 71 changed files in this pull request and generated 7 comments.

Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/platform/resources/access.py
Comment thread src/aignostics/platform/resources/access.py
Comment thread specifications/SPEC_PLATFORM_SERVICE.md Outdated
Comment thread specifications/SPEC_PLATFORM_SERVICE.md Outdated
Comment thread src/aignostics/application/_cli.py
Comment thread src/aignostics/application/_cli.py
Copilot AI review requested due to automatic review settings June 9, 2026 20:41
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@dima-aignostics dima-aignostics force-pushed the feat/PYSDK-132-add-run-sharing-to-python-sdk branch from 64cd279 to 6ea4f1f Compare June 9, 2026 20:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 71 changed files in this pull request and generated 3 comments.

Comment thread src/aignostics/platform/resources/runs.py
Comment thread src/aignostics/application/_service.py Outdated
Comment thread src/aignostics/application/_service.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 9, 2026 21:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 70 changed files in this pull request and generated 6 comments.

Comment thread src/aignostics/platform/resources/runs.py
Comment thread src/aignostics/application/_service.py Outdated
Comment thread src/aignostics/platform/resources/access.py
Comment thread requirements/SWR-APPLICATION-4-2.md
Comment thread requirements/SWR-APPLICATION-4-1.md
Comment thread requirements/SHR-APPLICATION-4.md
dima-aignostics and others added 2 commits June 9, 2026 23:24
…-based filtering

The service now cross-filters share tokens against active grants instead of
relying on ShareTokens.list(run_id=...). Update the unit test to wire up the
mock client (was missing mock_get_client.return_value), configure a matching
grant on the mock run, and assert that list_share_grants is called with the
correct arguments.

Also restore run_dont_commit.py to pyrightconfig.json ignore list.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 9, 2026 21:29
@sonarqubecloud

sonarqubecloud Bot commented Jun 9, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 16 out of 70 changed files in this pull request and generated 4 comments.

Comment thread src/aignostics/platform/resources/access.py
Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/application/_service.py
Comment thread src/aignostics/application/_service.py
@arne-aignx

Copy link
Copy Markdown
Collaborator

In addition to the SPECs outlined in the CR, we should also update the CLI Interface section in specifications/SPEC-APPLICATION-SERVICE.md with a short summary of the new commands

Comment on lines +1487 to +1491
console.print(f"Share token created for run '{run_id}'.")
console.print(f" Token ID : {token.share_token_id}")
console.print(f" Token : [bold]{token.share_token}[/bold]")
console.print(f" Expires : {expires}")
console.print("[yellow]Save the token value — it will not be shown again.[/yellow]")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

How would this token be consumed at a later point in time?

aignostics application run describe [OPTIONS] RUN_ID --share-token <TOKEN>?

Could we improve user experience through the CLI, if we prepare copyable commands, when print is used?

Comment thread tests/constants_test.py Outdated
Comment thread tests/constants_test.py Outdated
Comment on lines +10 to +13
System shall enable run submitters and organization admins to grant read access to a specific application run to another authenticated
platform user or to all users belonging to a specified organization. The system shall list all active access grants
for a given run, including for each grant the subject type, subject identifier, relation, and creation metadata.
The system shall revoke any individual grant on demand, removing the associated access immediately.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you think we can generalize these software requirements? Instead of replicating the details of the API requirements.

E.g. "System shall enable run owners and organization admins to manage user and organization access for a given application run through the CLI"

Comment on lines +10 to +14
System shall enable run submitters and organization admins to create revocable share tokens with an optional expiry date
and to grant read access to a specific application run via such a token, allowing secure sharing with other platform
users. The system shall list all active share tokens for the authenticated user. The system shall list all grants
associated with a given share token. The system shall revoke a share token's grant on a specific run on demand. The
token secret shall be returned only at creation time and shall not be retrievable subsequently.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Similar to above:
E.g. "System shall enable run owners and organization admins to manage share tokens for a given application run through the CLI"

self,
subject_type: SubjectType | None = None,
subject_id: str | None = None,
relation: list[GrantRelation] | None = None,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This filter is currently unreleased in PAPI Prod.
Do we need to sneak in a 1.6.1 release?

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.

3 participants