Skip to content

fix(core): poll, attach and log transform jobs through the session's region - #6411

Open
AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/transformer-session-region
Open

AkshayShah03 wants to merge 1 commit into
aws:masterfrom
AkshayShah03:fix/transformer-session-region

Conversation

@AkshayShah03

Copy link
Copy Markdown

Issue #, if available: N/A (same class of bug as #5796, fixed for processing jobs in #6369)

Description of changes:

Transformer doesn't carry its session's region through to the transform job:

  • transform() builds latest_transform_job = TransformJob(**transformed) without a client context. wait(), refresh() and stop() then use the process-default boto3 session and region. With a session in another region, the job is created there but polled in the default region.
  • attach() passes the SageMaker Session to TransformJob.get(session=...), which expects a boto3 Session, so Transformer.attach(name, sagemaker_session=...) always fails with ValidationError: session Input should be an instance of Session.
  • logs_for_transform_job has the same problem when describing the job through TransformJob.get(...).__dict__. It then reads PascalCase keys (TransformResources, TransformJobStatus) from that snake_case dict.

This change:

  • binds the job to the session's boto session and region with _set_client_context;
  • passes session=sagemaker_session.boto_session, region=sagemaker_session.boto_region_name to TransformJob.get in attach;
  • describes the job through sagemaker_session.sagemaker_client.describe_transform_job in logs_for_transform_job, matching fix(processing): respect session region when waiting for processing jobs #6369.

The generated TransformJob.wait(logs=True) builds its CloudWatch log handler without a session, so log streaming there still uses the default region. That's generated code, so I left it alone.

Testing:

  • test_transform_binds_job_to_session_region
  • test_attach_uses_boto_session_and_region
  • test_logs_for_transform_job_describes_with_session_client
  • All three fail before this change. tests/unit/test_transformer.py: 33 passed.

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

…region

Transformer did not carry its session's region through to the transform job:

- transform() built latest_transform_job with TransformJob(**transformed), so
  wait()/refresh()/stop() used the process-default boto3 session and region
  rather than the Transformer's sagemaker_session.
- attach() passed the SageMaker Session to TransformJob.get(session=...),
  which expects a boto3 Session, so attach always failed with a pydantic
  ValidationError.
- logs_for_transform_job described the job via TransformJob.get(...).__dict__
  (same session type error, default region) and then read PascalCase keys
  such as TransformResources/TransformJobStatus from that snake_case dict.

Bind the job to the session's boto session and region, pass them to
TransformJob.get in attach, and describe the job through
sagemaker_session.sagemaker_client in logs_for_transform_job, matching the
processing-job fix in aws#6369.

This branch is waiting to be deployed

1 waiting deployment
manual-approval — e3e56daa Waiting Oct 9, 2026 by AkshayShah03 via wait-for-approval #1963
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.

1 participant