-
Notifications
You must be signed in to change notification settings - Fork 127
fix: Fix/export outputs json cli flag #1138
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
Open
dferguson992
wants to merge
6
commits into
ai-dynamo:main
Choose a base branch
from
dferguson992:fix/export-outputs-json-cli-flag
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3b929f2
Fix for Issue #1133
frgud 4715584
feat: add --export-outputs-json CLI flag
frgud 6948b61
Fixing CI feedback
frgud ed112f9
Addressing CI and coverage
frgud 3184c99
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 60149db
Fixing Ruff spots
frgud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| """Tests for --profile-export-prefix / --export-outputs-json path collision guard. | ||
|
|
||
| When both flags are active and the prefix resolves to 'outputs', the summary | ||
| JSON (`outputs.json`) and the generated-output export (`outputs.json`) would | ||
| target the same file. The model validator must reject this combination. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
| from pydantic import ValidationError | ||
| from pytest import param | ||
|
|
||
| from aiperf.config.artifacts import ArtifactsConfig | ||
| from aiperf.config.flags.cli_config import CLIConfig | ||
| from aiperf.config.flags.converter import convert_cli_to_aiperf | ||
|
|
||
|
|
||
| class TestOutputsJsonPrefixCollision: | ||
| """ArtifactsConfig.validate_artifacts rejects colliding prefix + export_outputs_json.""" | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "prefix", | ||
| [ | ||
| param("outputs", id="bare"), | ||
| param("outputs.json", id="with-json-suffix"), | ||
| param("outputs.jsonl", id="with-jsonl-suffix"), | ||
| param("outputs.csv", id="with-csv-suffix"), | ||
| param("outputs_raw.jsonl", id="with-raw-suffix"), | ||
| param("outputs_timeslices.json", id="with-timeslices-suffix"), | ||
| ], | ||
| ) # fmt: skip | ||
| def test_validate_artifacts_colliding_prefix_raises_error( | ||
| self, prefix: str | ||
| ) -> None: | ||
| with pytest.raises( | ||
| ValidationError, match="colliding with --export-outputs-json" | ||
| ): | ||
| ArtifactsConfig(prefix=prefix, export_outputs_json=True) | ||
|
|
||
| def test_validate_artifacts_colliding_prefix_without_export_allows(self) -> None: | ||
| cfg = ArtifactsConfig(prefix="outputs", export_outputs_json=False) | ||
| assert cfg.profile_export_json_file.name == "outputs.json" | ||
|
|
||
| def test_validate_artifacts_non_colliding_prefix_with_export_allows(self) -> None: | ||
| cfg = ArtifactsConfig(prefix="foo", export_outputs_json=True) | ||
| assert cfg.profile_export_json_file.name == "foo.json" | ||
| assert cfg.outputs_json_file.name == "outputs.json" | ||
|
|
||
| def test_validate_artifacts_no_prefix_with_export_allows(self) -> None: | ||
| cfg = ArtifactsConfig(export_outputs_json=True) | ||
| assert cfg.profile_export_json_file.name == "profile_export_aiperf.json" | ||
| assert cfg.outputs_json_file.name == "outputs.json" | ||
|
|
||
|
|
||
| class TestOutputsJsonPrefixCollisionCLI: | ||
| """End-to-end: CLI converter propagates the collision to ArtifactsConfig validation.""" | ||
|
|
||
| def test_convert_cli_to_aiperf_colliding_prefix_with_export_raises_error( | ||
| self, | ||
| ) -> None: | ||
| cli = CLIConfig( | ||
| model_names=["m"], | ||
| profile_export_prefix="outputs", | ||
| export_outputs_json=True, | ||
| ) | ||
| with pytest.raises( | ||
| ValidationError, match="colliding with --export-outputs-json" | ||
| ): | ||
| convert_cli_to_aiperf(cli) | ||
|
|
||
| def test_convert_cli_to_aiperf_colliding_prefix_without_export_allows(self) -> None: | ||
| cli = CLIConfig(model_names=["m"], profile_export_prefix="outputs") | ||
| cfg = convert_cli_to_aiperf(cli) | ||
| assert cfg.benchmark.artifacts.profile_export_json_file.name == "outputs.json" |
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
Oops, something went wrong.
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.