Skip to content

fix: Fix/export outputs json cli flag#1138

Open
dferguson992 wants to merge 6 commits into
ai-dynamo:mainfrom
dferguson992:fix/export-outputs-json-cli-flag
Open

fix: Fix/export outputs json cli flag#1138
dferguson992 wants to merge 6 commits into
ai-dynamo:mainfrom
dferguson992:fix/export-outputs-json-cli-flag

Conversation

@dferguson992

@dferguson992 dferguson992 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Attempts to fix Issue #1133

Summary by CodeRabbit

  • New Features

    • Added --export-outputs-json to export each request’s generated response text to an outputs.json file in the artifacts directory (for both profiling and service workflows).
  • Bug Fixes

    • Prevents collisions between --profile-export-prefix and the generated outputs target when export is enabled.
    • Clears stale output fragment files from prior failed runs before exporting.
    • Refines when record outputs are included based on whether export_level was explicitly set.
  • Documentation

    • Expanded CLI options documentation, including defaults for repeatable list-style flags and the new export behavior.
  • Tests

    • Added unit and CLI-level coverage for the collision guard and fragment cleanup.

frgud added 2 commits July 9, 2026 09:39
Signed-off-by: Dan Ferguson <frgud@amazon.com>
Restore CLI flag binding for export_outputs_json, which controls
whether outputs.json (the raw generated-response-text dump) is
written after a benchmark run.

The setting was only reachable via the nested YAML config field
benchmark.artifacts.export_outputs_json. This adds a top-level
--export-outputs-json flag to the profile command.

Closes ai-dynamo#1133

Signed-off-by: Dan Ferguson <frgud@amazon.com>
@copy-pr-bot

copy-pr-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Try out this PR

Quick install:

pip install --upgrade --force-reinstall git+https://github.com/ai-dynamo/aiperf.git@f580d20828005846f5cffc3d7488b05d0a9bbf55

Recommended with virtual environment (using uv):

uv venv --python 3.12 && source .venv/bin/activate
uv pip install --upgrade --force-reinstall git+https://github.com/ai-dynamo/aiperf.git@f580d20828005846f5cffc3d7488b05d0a9bbf55

Last updated for commit: f580d20Browse code

@dferguson992 dferguson992 changed the title Fix/export outputs json cli flag fix: Fix/export outputs json cli flag Jul 9, 2026
@github-actions github-actions Bot added the fix label Jul 9, 2026
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds the --export-outputs-json CLI flag as an optional output setting, propagates it through artifact configuration, validates filename collisions, removes stale output fragments before export, and documents the option for profile and service commands.

Changes

Export Outputs JSON Flow

Layer / File(s) Summary
CLI field, section wiring, and artifact propagation
src/aiperf/config/flags/cli_config.py, src/aiperf/config/flags/_section_fields.py, src/aiperf/config/flags/_converter_runtime.py
Adds the optional output field, registers it in OUTPUT_FIELDS, propagates explicitly set values, and updates explicit export_level handling for records.
Artifact collision validation and tests
src/aiperf/config/artifacts.py, tests/unit/config/test_outputs_json_prefix_collision.py
Rejects prefixes that would make the profile JSON summary collide with outputs.json, with configuration and CLI conversion coverage.
Stale fragment cleanup and tests
src/aiperf/config/resolution/resolvers.py, tests/unit/config/test_resolvers.py
Deletes stale output fragment JSONL files before user files are materialized when outputs JSON export is enabled, while preserving them when export is disabled.
CLI documentation
docs/cli-options.md
Documents the new flag for profile and service commands and adds explicit empty-list defaults for mirrored repeatable options.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Poem

A rabbit flips the export switch,
And clears old crumbs from every ditch.
If names collide, the guard says “no,”
While fresh JSON files neatly grow.
🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly refers to the new export outputs JSON CLI flag, which is the main change in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.47368% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/aiperf/config/flags/_converter_runtime.py 80.00% 0 Missing and 1 partial ⚠️
src/aiperf/config/resolution/resolvers.py 85.71% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@ajcasagrande ajcasagrande left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for adding the CLI wiring for outputs.json; the basic happy path works — I verified --export-outputs-json with the real aiperf profile CLI against the in-repo mock server and it produced the expected generated-output records, and the related unit tests pass.

I found three issues to address before merging, in this order:

  1. Fix the --profile-export-prefix outputs collision first; it corrupts outputs.json into invalid JSON.
  2. Clean or scope output_fragments so retries after failed runs cannot mix stale responses into the new artifact.
  3. Decide whether --export-outputs-json should force per-record JSONL when YAML had artifacts.records: false; if yes, document it explicitly, otherwise avoid emitting records unless --export-level was set.

Comment thread src/aiperf/config/flags/cli_config.py
Comment thread src/aiperf/config/flags/_converter_runtime.py
Comment thread src/aiperf/config/flags/cli_config.py
@datadog-official

This comment has been minimized.

Signed-off-by: Dan Ferguson <frgud@amazon.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
tests/unit/config/test_outputs_json_prefix_collision.py (1)

24-39: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add normalized-path collision cases.

The parameter list covers suffix stripping but not prefixes such as ./outputs or sub/../outputs; these currently bypass the new guard.

Proposed test cases
             param("outputs_timeslices.json", id="with-timeslices-suffix"),
+            param("./outputs", id="dot-path"),
+            param("sub/../outputs", id="normalized-path"),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/config/test_outputs_json_prefix_collision.py` around lines 24 -
39, Add parameterized cases for normalized equivalent prefixes, including
"./outputs" and "sub/../outputs", to test_rejects_colliding_prefix in the
existing prefix list. Keep the expected ValidationError assertion unchanged so
ArtifactsConfig rejects these paths when export_outputs_json is enabled.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/aiperf/config/artifacts.py`:
- Around line 224-235: Update _check_outputs_json_collision to compare
normalized filesystem paths rather than raw strings: resolve
self.profile_export_json_file and self.outputs_json_file and reject them when
equal, preserving the existing base/optional-prefix handling.

In `@tests/unit/config/test_outputs_json_prefix_collision.py`:
- Around line 35-39: Rename the affected tests to follow
test_<function>_<scenario>_<expected>, including the tested function, scenario,
and outcome; for example, rename the ArtifactsConfig collision test to
test_artifacts_config_rejects_colliding_prefix and apply equivalent descriptive
names to the tests covering convert_cli_to_aiperf and the other indicated cases.

---

Nitpick comments:
In `@tests/unit/config/test_outputs_json_prefix_collision.py`:
- Around line 24-39: Add parameterized cases for normalized equivalent prefixes,
including "./outputs" and "sub/../outputs", to test_rejects_colliding_prefix in
the existing prefix list. Keep the expected ValidationError assertion unchanged
so ArtifactsConfig rejects these paths when export_outputs_json is enabled.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 28ce16bc-41e2-4794-8856-d0c211bc253c

📥 Commits

Reviewing files that changed from the base of the PR and between 18c0027 and 8848bb9.

📒 Files selected for processing (5)
  • docs/cli-options.md
  • src/aiperf/config/artifacts.py
  • src/aiperf/config/flags/_converter_runtime.py
  • src/aiperf/config/resolution/resolvers.py
  • tests/unit/config/test_outputs_json_prefix_collision.py

Comment thread src/aiperf/config/artifacts.py Outdated
Comment thread tests/unit/config/test_outputs_json_prefix_collision.py Outdated
Comment thread src/aiperf/config/artifacts.py Outdated
frgud and others added 2 commits July 10, 2026 16:19
Signed-off-by: Dan Ferguson <frgud@amazon.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/unit/config/test_resolvers.py (1)

272-287: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add type annotations to the new test methods.

Annotate the fixture parameters and return types, for example with the project’s config type, Path, and -> None.

As per coding guidelines, add type hints to all Python function parameters and return values.

Also applies to: 289-307

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/unit/config/test_resolvers.py` around lines 272 - 287, The new test
methods, including test_resolve_purges_stale_output_fragments and the methods
around lines 289-307, lack type annotations. Add types for every fixture
parameter using the project’s config type and Path where applicable, and
annotate each test method with -> None.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/unit/config/test_resolvers.py`:
- Around line 272-287: The new test methods, including
test_resolve_purges_stale_output_fragments and the methods around lines 289-307,
lack type annotations. Add types for every fixture parameter using the project’s
config type and Path where applicable, and annotate each test method with ->
None.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8eb70bfa-3e28-405f-a407-cebd90d62f57

📥 Commits

Reviewing files that changed from the base of the PR and between 8848bb9 and f580d20.

📒 Files selected for processing (3)
  • src/aiperf/config/artifacts.py
  • tests/unit/config/test_outputs_json_prefix_collision.py
  • tests/unit/config/test_resolvers.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/aiperf/config/artifacts.py
  • tests/unit/config/test_outputs_json_prefix_collision.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants