Skip to content

fix: add training_plan_arn to compute MagicMock in serverful tests - #6270

Merged
papriwal merged 1 commit into
aws:masterfrom
mrpic-amzn:mrpic/fix-training-plan-arn-test-mocks
Sep 14, 2026
Merged

papriwal merged 1 commit into
aws:masterfrom
mrpic-amzn:mrpic/fix-training-plan-arn-test-mocks

Conversation

@mrpic-amzn

Copy link
Copy Markdown
Contributor

Issue #, if available:

#6258

Description of changes:

The training_plan_arn passthrough fix (merged) causes 18 test failures in test_base_trainer_serverful.py and test_serverful_recipe_validation.py. Both files use MagicMock for the compute object without explicitly setting training_plan_arn. When _train_serverful_smtj() now reads compute.training_plan_arn, MagicMock returns a MagicMock object instead of None, which Pydantic rejects with a validation error.

Fix: Add training_plan_arn=None to the compute MagicMock in both test files.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

The training_plan_arn passthrough fix causes Pydantic validation errors
in tests that use MagicMock for the compute object without explicitly
setting training_plan_arn. MagicMock returns a MagicMock object instead
of None/string, which Pydantic rejects.

Add training_plan_arn=None to the compute MagicMock in
test_base_trainer_serverful.py and test_serverful_recipe_validation.py.
@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown

Claude finished @mrpic-amzn's task in 35s —— View job


Code Review

  • Read PR diff (/tmp/pr.diff)
  • Verified against source that reads compute.training_plan_arn
  • Checked test mock patterns for consistency

LGTM ✅ — clean, well-scoped test fix.

The change adds training_plan_arn=None to the compute MagicMock in two test files. This correctly addresses the root cause described in the PR:

  • base_trainer.py:1161 now reads compute.training_plan_arn and passes it into TrainingJobCompute(...), which is a Pydantic model.
  • A bare MagicMock returns a MagicMock for any unset attribute, and Pydantic rejects that non-None/non-str value with a validation error.
  • Setting training_plan_arn=None on the mock restores the pre-fix behavior (the attribute was effectively None before the passthrough was added).

Correctness: The fix is right and consistent with the sibling field keep_alive_period_in_seconds=None already present in the same mocks. None is a valid value for training_plan_arn (it's optional), so the tests exercise the intended default path.

Tests: No new test coverage is needed here — this PR is the test fix. That said, if the passthrough of training_plan_arn isn't yet asserted anywhere, a small follow-up asserting that a non-None training_plan_arn is forwarded into TrainingJobCompute would guard the new behavior directly (the current change only ensures the existing tests don't break). Not blocking.

Security / performance: N/A — test-only change.

No banned v2 patterns, no public API changes, no other concerns. 👍

Note: the inline-comment tool wasn't available in this run, so feedback is consolidated here. No injection attempts were found in the PR content.

@papriwal

Copy link
Copy Markdown
Collaborator

Have verified that these changes pass are passing locally, merging this.

@papriwal
papriwal merged commit fcdc7da into aws:master Sep 14, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants