Skip to content

fix(jobs): forward transformed plugin job specs in JSON mode - #748

Merged
arpitsardhana merged 2 commits into
mainfrom
fix-nvbugs-july-16-6466868
Jul 17, 2026
Merged

fix(jobs): forward transformed plugin job specs in JSON mode#748
arpitsardhana merged 2 commits into
mainfrom
fix-nvbugs-july-16-6466868

Conversation

@arpitsardhana

@arpitsardhana arpitsardhana commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix HTTP 500 on evaluator durable-job submit when metrics use cloudpickle bundles (non-UTF-8 binary payloads in EvaluateSpec).
  • Dump transformed plugin job specs with model_dump(mode="json") before forwarding to core jobs so bytes fields serialize as base64 instead of raw bytes.
  • Add unit test asserting the create-job route forwards JSON-safe transformed specs.

Fixes: https://nvbugspro.nvidia.com/bug/6466868

Root cause

The generated plugin create_job route re-dumped transformed specs in Python mode. Cloudpickle metric bundle blob fields stayed as raw bytes, which failed JSON serialization in the typed jobs client (PydanticSerializationError: invalid utf-8 sequence).

Test plan

  • uv run --frozen pytest packages/nemo_platform_plugin/tests/test_jobs_create_spec_json.py -v
  • uv run python repro_cloudpickle_eval.py against a live local platform (optional manual check)

NVBugs #6466868

Summary by CodeRabbit

  • Bug Fixes
    • Fixed job creation so Pydantic job specifications are serialized using JSON-mode, ensuring binary-like fields are sent as base64-encoded strings.
    • Improved compatibility with typed clients by guaranteeing the submitted job payload is fully JSON-serializable.
  • Tests
    • Added a regression test covering JSON-mode serialization for transformed job specs containing binary data.

Cloudpickle metric bundles embed non-UTF-8 bytes in EvaluateSpec payloads.
Dumping the transformed spec in Python mode left raw bytes in the body
forwarded to core jobs, causing PydanticSerializationError and HTTP 500
on evaluator durable-job submit. Use model_dump(mode="json") so binary
fields serialize as base64.

NVBugs #6466868

Signed-off-by: Arpit Singh (SW-CLOUD) <arpsingh@nvidia.com>
@arpitsardhana
arpitsardhana requested review from a team as code owners July 17, 2026 00:21
@github-actions github-actions Bot added the fix label Jul 17, 2026
Signed-off-by: Arpit Singh (SW-CLOUD) <arpsingh@nvidia.com>
@coderabbitai

coderabbitai Bot commented Jul 17, 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: 21bbf9f7-878e-4c30-b688-5b1e29ffdbb1

📥 Commits

Reviewing files that changed from the base of the PR and between b5877d3 and 1f5561c.

📒 Files selected for processing (1)
  • packages/nemo_platform_plugin/tests/test_jobs_create_spec_json.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/nemo_platform_plugin/tests/test_jobs_create_spec_json.py

📝 Walkthrough

Walkthrough

Changes

Job specification JSON serialization

Layer / File(s) Summary
JSON-mode job specification serialization
packages/nemo_platform_plugin/src/nemo_platform_plugin/jobs/api_factory.py
create_job now uses model_dump(mode="json") so binary-like fields are serialized for JSON transport.
Binary payload regression coverage
packages/nemo_platform_plugin/tests/test_jobs_create_spec_json.py
Adds a FastAPI job-creation test verifying binary output is base64-encoded and the forwarded payload is JSON-serializable.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main fix: forwarding transformed job specs in JSON mode.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-nvbugs-july-16-6466868

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 `@packages/nemo_platform_plugin/src/nemo_platform_plugin/jobs/api_factory.py`:
- Around line 876-877: Update the transformed-spec handling around job_spec and
spec_dict to enforce JSON-safe output for both BaseModel and raw-dict results
before constructing the SDK body. Configure or apply base64 normalization for
binary fields, including non-UTF-8 bytes, and validate raw transformer
dictionaries rather than passing them through unchanged.
🪄 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: 708c7baf-71bd-433a-8a3a-09c9772b6ce3

📥 Commits

Reviewing files that changed from the base of the PR and between 2412ab7 and b5877d3.

📒 Files selected for processing (2)
  • packages/nemo_platform_plugin/src/nemo_platform_plugin/jobs/api_factory.py
  • packages/nemo_platform_plugin/tests/test_jobs_create_spec_json.py

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 25533/32734 78.0% 62.7%
Integration Tests 14731/31383 46.9% 19.2%

@arpitsardhana
arpitsardhana added this pull request to the merge queue Jul 17, 2026
Merged via the queue into main with commit cbc5ce8 Jul 17, 2026
58 checks passed
@arpitsardhana
arpitsardhana deleted the fix-nvbugs-july-16-6466868 branch July 17, 2026 15:50
soluwalana pushed a commit that referenced this pull request Jul 17, 2026
* fix(jobs): forward transformed plugin job specs in JSON mode

Cloudpickle metric bundles embed non-UTF-8 bytes in EvaluateSpec payloads.
Dumping the transformed spec in Python mode left raw bytes in the body
forwarded to core jobs, causing PydanticSerializationError and HTTP 500
on evaluator durable-job submit. Use model_dump(mode="json") so binary
fields serialize as base64.

NVBugs #6466868

Signed-off-by: Arpit Singh (SW-CLOUD) <arpsingh@nvidia.com>

* chore: remove unused AsyncMock import in jobs spec JSON test

Signed-off-by: Arpit Singh (SW-CLOUD) <arpsingh@nvidia.com>

---------

Signed-off-by: Arpit Singh (SW-CLOUD) <arpsingh@nvidia.com>
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.

2 participants