Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 5
fix(application): Include items in run describe --format=json#437
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -935,9 +935,11 @@ def run_describe( | ||
| user_info = PlatformService.get_user_info() | ||
| run = Service().application_run(run_id) | ||
| if format == "json": | ||
| # Get run details and output as JSON | ||
| # Get run details and items, output as JSON | ||
| run_details = run.details(hide_platform_queue_position=not user_info.is_internal_user) | ||
| print(json.dumps(run_details.model_dump(mode="json"), indent=2, default=str)) | ||
| run_data = run_details.model_dump(mode="json") | ||
| run_data["items"] = [item.model_dump(mode="json") for item in run.results()] | ||
olivermeyer marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| print(json.dumps(run_data, indent=2, default=str)) | ||
| else: | ||
| retrieve_and_print_run_details( | ||
| run, hide_platform_queue_position=not user_info.is_internal_user, summarize=summarize | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -696,6 +696,90 @@ def test_cli_run_describe_not_found(runner: CliRunner, record_property) -> None: | ||
| assert "Warning: Run with ID '00000000000000000000000000000000' not found." in normalize_output(result.stdout) | ||
| @pytest.mark.integration | ||
olivermeyer marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| def test_cli_run_describe_json_includes_items(runner: CliRunner) -> None: | ||
| """Check run describe --format=json includes items in output.""" | ||
| from aignx.codegen.models import ( | ||
| ItemOutput, | ||
| ItemResultReadResponse, | ||
| ItemState, | ||
| ItemTerminationReason, | ||
| RunItemStatistics, | ||
| RunOutput, | ||
| RunReadResponse, | ||
| RunState, | ||
| RunTerminationReason, | ||
| ) | ||
| mock_run_data = RunReadResponse( | ||
| run_id="test-run-id-123", | ||
| application_id="test-app", | ||
| version_number="1.0.0", | ||
| state=RunState.TERMINATED, | ||
| output=RunOutput.FULL, | ||
| termination_reason=RunTerminationReason.ALL_ITEMS_PROCESSED, | ||
| error_code=None, | ||
| error_message=None, | ||
| statistics=RunItemStatistics( | ||
| item_count=1, | ||
| item_pending_count=0, | ||
| item_processing_count=0, | ||
| item_user_error_count=0, | ||
| item_system_error_count=0, | ||
| item_skipped_count=0, | ||
| item_succeeded_count=1, | ||
| ), | ||
| custom_metadata=None, | ||
| submitted_at=datetime(2025, 1, 1, tzinfo=UTC), | ||
| submitted_by="test-user", | ||
| terminated_at=datetime(2025, 1, 1, 0, 5, tzinfo=UTC), | ||
| ) | ||
| mock_item = ItemResultReadResponse( | ||
| item_id="item-id-456", | ||
| external_id="slide-001.svs", | ||
| custom_metadata={"key": "value"}, | ||
| state=ItemState.TERMINATED, | ||
| output=ItemOutput.FULL, | ||
| termination_reason=ItemTerminationReason.SUCCEEDED, | ||
| error_message=None, | ||
| error_code=None, | ||
| output_artifacts=[], | ||
| ) | ||
| mock_user_info = MagicMock() | ||
| mock_user_info.is_internal_user = False | ||
| mock_run_handle = MagicMock() | ||
| mock_run_handle.details.return_value = mock_run_data | ||
| mock_run_handle.results.return_value = iter([mock_item]) | ||
| with ( | ||
| patch("aignostics.application._cli.PlatformService.get_user_info", return_value=mock_user_info), | ||
| patch("aignostics.application._cli.Service") as mock_service_cls, | ||
| ): | ||
| mock_service_cls.return_value.application_run.return_value = mock_run_handle | ||
| result = runner.invoke(cli, ["application", "run", "describe", "test-run-id-123", "--format", "json"]) | ||
| assert result.exit_code == 0, f"Command failed with output: {result.stdout}" | ||
| output_data = json.loads(result.stdout) | ||
| # Verify run-level fields are present | ||
| assert output_data["run_id"] == "test-run-id-123" | ||
| assert output_data["application_id"] == "test-app" | ||
| # Verify items are included | ||
| assert "items" in output_data, "JSON output must include 'items' key" | ||
| assert len(output_data["items"]) == 1 | ||
| item = output_data["items"][0] | ||
| assert item["item_id"] == "item-id-456" | ||
| assert item["external_id"] == "slide-001.svs" | ||
| assert item["custom_metadata"] == {"key": "value"} | ||
| assert item["state"] == "TERMINATED" | ||
| assert item["termination_reason"] == "SUCCEEDED" | ||
| @pytest.mark.e2e | ||
| def test_cli_run_cancel_invalid_run_id(runner: CliRunner, record_property) -> None: | ||
| """Check run cancel command fails as expected on run not found.""" | ||
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.