Skip to content

fix(auditor): connect aggregated artifacts download - #1141

Open
parkanzky wants to merge 2 commits into
mainfrom
nvbug6562262-aggregate-artifacts
Open

fix(auditor): connect aggregated artifacts download#1141
parkanzky wants to merge 2 commits into
mainfrom
nvbug6562262-aggregate-artifacts

Conversation

@parkanzky

@parkanzky parkanzky commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

QA found that aggregated artifacts were not available for download while SDK included download path. Added aggregated artifacts to download path.

Changes

Connected the aggregate download artifact API path. Results in tgz file. This was already in the docs, so made code match.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with documentation updates
  • Documentation only
  • Contributor tooling or automation
  • CI, build, or test infrastructure

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification: Documentation existed for phantom functionality.

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Targeted validation:

Summary by CodeRabbit

  • New Features

    • Added an artifact download endpoint for audit jobs.
    • Users can download available audit result artifacts as a compressed archive.
    • Missing artifacts are skipped; a not-found response is returned when no results are available.
  • Bug Fixes

    • Improved job result route configuration to support either custom handlers or serializers, with validation for incomplete configurations.
  • Documentation

    • Removed the CLI reference documentation.

@parkanzky
parkanzky requested review from a team as code owners August 6, 2026 21:05
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 8581aa48-9fd9-485f-a7ad-2448a3c88aec

📥 Commits

Reviewing files that changed from the base of the PR and between 2d25d16 and 650d1f5.

📒 Files selected for processing (2)
  • docs/cli/reference.mdx
  • packages/nemo_platform/pyproject.toml
💤 Files with no reviewable changes (1)
  • docs/cli/reference.mdx

📝 Walkthrough

Walkthrough

Platform result routes now support custom async handlers. The auditor adds a GET route that downloads configured Garak artifacts as a temporary gzip tar archive, with 404 handling, cleanup scheduling, route registration, and tests.

Changes

Auditor artifact download

Layer / File(s) Summary
Custom result-route contract
packages/nemo_platform_plugin/src/nemo_platform_plugin/jobs/api_factory.py
PlatformJobResultRoute accepts a serializer or async handler. Validation rejects routes with neither. Registered handlers use direct FileResponse dispatch.
Artifact aggregation handler
plugins/nemo-auditor/src/nemo_auditor/jobs/artifacts_route.py, plugins/nemo-auditor/src/nemo_auditor/jobs/audit.py, plugins/nemo-auditor/tests/test_artifacts_route.py
The handler filters Garak results, downloads available artifacts, creates artifacts.tar.gz, schedules cleanup, and returns 404 when no matching results exist. Tests cover complete, partial, unrecognized, and empty result sets.
Auditor route registration and coverage
plugins/nemo-auditor/src/nemo_auditor/service.py, plugins/nemo-auditor/tests/test_service.py, packages/nemo_platform/pyproject.toml
The auditor registers the authorized GET artifacts result route. Tests verify method-specific route discovery and mounting. The package metadata adds table separation whitespace.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant AuditorRoute
  participant AsyncNeMoPlatform
  participant ArchiveStorage
  Client->>AuditorRoute: Request job artifacts
  AuditorRoute->>AsyncNeMoPlatform: List and download Garak results
  AuditorRoute->>ArchiveStorage: Create temporary artifacts.tar.gz
  AuditorRoute-->>Client: Return archive or HTTP 404
Loading

Possibly related PRs

Suggested labels: test

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.75% 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 identifies the auditor change that connects aggregated artifact downloads.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch nvbug6562262-aggregate-artifacts

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

@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: 1

🤖 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 `@plugins/nemo-auditor/src/nemo_auditor/jobs/artifacts_route.py`:
- Around line 38-55: Update the artifact aggregation flow around
download_from_result_info and tar.add to synchronously clean all accumulated
temporary result directories and agg_tmp when either operation fails, then
re-raise the exception. Schedule background cleanup tasks only after the archive
is created successfully, and add a test covering cleanup after a failed
download.
🪄 Autofix

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: 643b16a0-3748-4df1-83f6-d66734bec9b9

📥 Commits

Reviewing files that changed from the base of the PR and between c71ca67 and 2d25d16.

📒 Files selected for processing (6)
  • packages/nemo_platform_plugin/src/nemo_platform_plugin/jobs/api_factory.py
  • plugins/nemo-auditor/src/nemo_auditor/jobs/artifacts_route.py
  • plugins/nemo-auditor/src/nemo_auditor/jobs/audit.py
  • plugins/nemo-auditor/src/nemo_auditor/service.py
  • plugins/nemo-auditor/tests/test_artifacts_route.py
  • plugins/nemo-auditor/tests/test_service.py

Comment on lines +38 to +55
tmp_dirs = []
for result in relevant:
filename, tmp_dir_path = await download_from_result_info(
result_name=result.name,
job_name=job,
workspace=workspace,
artifact_url=result.artifact_url,
files_sdk=sdk,
)
tmp_dirs.append((filename, tmp_dir_path))
background_tasks.add_task(tmp_dir_path.cleanup_tmp_dir)

agg_tmp = Path(tempfile.mkdtemp())
tar_path = agg_tmp / "artifacts.tar.gz"
with tarfile.open(tar_path, "w:gz") as tar:
for filename, tmp_dir_path in tmp_dirs:
tar.add(tmp_dir_path.path, arcname=filename)
background_tasks.add_task(lambda: shutil.rmtree(agg_tmp, ignore_errors=True))

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.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Clean up temporary directories on failure.

If download_from_result_info or tar.add raises, the endpoint returns no FileResponse. FastAPI does not run these scheduled background tasks. The successful downloads then leak temporary directories.

Use try/except to clean accumulated result directories and agg_tmp synchronously before re-raising. Schedule background cleanup only after archive creation succeeds. Add a failed-download test.

🤖 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 `@plugins/nemo-auditor/src/nemo_auditor/jobs/artifacts_route.py` around lines
38 - 55, Update the artifact aggregation flow around download_from_result_info
and tar.add to synchronously clean all accumulated temporary result directories
and agg_tmp when either operation fails, then re-raise the exception. Schedule
background cleanup tasks only after the archive is created successfully, and add
a test covering cleanup after a failed download.

Signed-off-by: Paul A. Parkanzky <[email protected]>
@parkanzky
parkanzky force-pushed the nvbug6562262-aggregate-artifacts branch from 2d25d16 to 650d1f5 Compare August 7, 2026 14:48
@github-actions github-actions Bot added the fix label Aug 7, 2026
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 31452/40078 78.5% 63.0%
Integration Tests 18319/38030 48.2% 20.8%

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.

1 participant