Repository navigation
fix: put the check steps' output KMS key on ProcessingOutputConfig and send CheckJobConfig tags - #6497
Conversation
…d send CheckJobConfig tags QualityCheckStep.arguments and ClarifyCheckStep.arguments build their CreateProcessingJob request by hand. Both put KmsKeyId inside ProcessingS3Output, which the API does not accept - KmsKeyId belongs on ProcessingOutputConfig, where it applies to every output. Both also never read check_job_config.tags, so configured tags were dropped. Validating the pre-fix request against the CreateProcessingJob service model reports: Unknown parameter in ProcessingOutputConfig.Outputs[0].S3Output: "KmsKeyId", must be one of: S3Uri, LocalPath, S3UploadMode Both are v2 -> v3 regressions. In v2 the request came from Session._get_process_request via Processor._get_process_args, which set output_config["KmsKeyId"] and request["Tags"]; the v3 hand-rolled builders lost both. The two builders were identical apart from the inputs, the output and the default job name, so the shaping moves into a shared _build_check_job_request helper. The fix then lands once and the two steps can no longer drift. Fixes aws#6495
There was a problem hiding this comment.
🤖 AI code review
This PR fixes two v2→v3 regressions in the check steps' hand-built CreateProcessingJob request: it moves KmsKeyId from ProcessingS3Output (where the API rejects it) to ProcessingOutputConfig, and propagates CheckJobConfig.tags as Tags. The ~70 duplicated lines in QualityCheckStep.arguments and ClarifyCheckStep.arguments are extracted into a shared _build_check_job_request helper. I verified CheckJobConfig.tags exists (normalized via format_tags into the correct [{"Key","Value"}] shape), that all imports (RequestType, ProcessingInput, ProcessingOutput) resolve at the base commit, and that the refactor preserves the original None/empty-input handling and getattr defaults. The change matches the guidance in issue #6495 and is well covered by new/updated unit tests (including a ParamValidator guard against the service model) and integ tests. No issues found.
Reviewed commit 3924572. Automated review; verify before acting.
Issue
Fixes #6495
QualityCheckStep.argumentsandClarifyCheckStep.argumentsbuild theirCreateProcessingJobrequest by hand, and the hand-rolled shape is wrong in two places:KmsKeyIdis placed insideProcessingS3Output. The API does not accept it there — it belongs onProcessingOutputConfig, where it applies to every output.check_job_config.tagsis never read, so tags configured onCheckJobConfigare silently dropped.Validating the pre-fix request against the
CreateProcessingJobservice model (botocore.validate.ParamValidator) reports:Both are v2 → v3 regressions. In v2 the request came from
Session._get_process_requestviaProcessor._get_process_args, which setoutput_config["KmsKeyId"]andrequest["Tags"] = processor.tags. The v3 hand-rolled builders lost both.ClarifyCheckStepis affected identically — the issue reportsQualityCheckStep, but the twoargumentsproperties are the same code, so the same request is malformed for every check step.Fix
Move
KmsKeyIdontoProcessingOutputConfigand addTagsfromcheck_job_config.tags(omitted when unset or empty, rather than sent empty).The two builders were identical apart from the inputs, the output and the default job name, so the ~70 duplicated lines move into a shared
_build_check_job_requesthelper in a new privatesagemaker/mlops/workflow/_check_job_request.py. The fix then lands once and the two steps can no longer drift. Each step keeps its owntrim_request_dictcall, since that is about the pipeline definition rather than the processing request.Before:
{ "ProcessingOutputConfig": { "Outputs": [{"S3Output": {"KmsKeyId": "arn:aws:kms:..."}}] } }After:
{ "ProcessingOutputConfig": { "Outputs": [{"S3Output": {"S3Uri": "...", "LocalPath": "...", "S3UploadMode": "EndOfJob"}}], "KmsKeyId": "arn:aws:kms:..." }, "Tags": [{"Key": "test", "Value": "quality-check"}] }No behavior other than the two fields changes: every other field name, default (
VolumeSizeInGB30,MaxRuntimeInSeconds86400) and optional-field condition is carried over unchanged, including thegetattrfallbacks.Testing
Reproduced the issue first with the script from #6495 (offline, mocked boto session): pre-fix
ProcessingOutputConfig.KmsKeyIdisNone,Outputs[0].S3Output.KmsKeyIdis set andTagsis absent. Post-fix that inverts.sagemaker-mlops/tests/unit/workflow/test_check_job_request.py(11 tests) covers the shared builder, including a guard that validates the produced request against the realCreateProcessingJobinput shape viabotocore.validate.ParamValidator— the pre-fix shape fails this check, so the regression cannot come back silently. Also covers tag omission when unset/empty, inputs with nos3_input, empty inputs, the default job name fallback, the optional processor fields and theVolumeSizeInGB/MaxRuntimeInSecondsdefaults.test_quality_check_step_kms.pyandtest_clarify_check_step_kms.py: these pinned the incorrectS3Output.KmsKeyIdplacement, so they now assertProcessingOutputConfig.KmsKeyIdand thatS3Outputhas noKmsKeyId, plus newTagspropagation classes.tests/integ/test_check_step_kms_propagation.pyfor the corrected placement and added tag coverage.Against pre-fix source the updated unit tests fail 12 / pass 12; with the fix all pass. Full
sagemaker-mlops/tests/unit/workflowsuite: 412 passed.black(100) clean,flake8(120) clean,pylint10.00/10 on the new module,pydocstyleclean.Backwards compatibility
The emitted request becomes valid where it was previously rejected by the API, and tags configured on
CheckJobConfignow reach the job as documented. Pipeline definitions that previously carriedS3Output.KmsKeyIdwill serialize it underProcessingOutputConfigon their next upsert; no public API, signature or default changes.