Skip to content

fix: refresh sagemaker-core service model and regenerate SDK#5800

Closed
lucasjia-aws wants to merge 9 commits into
aws:masterfrom
lucasjia-aws:master
Closed

fix: refresh sagemaker-core service model and regenerate SDK#5800
lucasjia-aws wants to merge 9 commits into
aws:masterfrom
lucasjia-aws:master

Conversation

@lucasjia-aws

@lucasjia-aws lucasjia-aws commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Issue

The service-2.json bundled in sagemaker-core had drifted from the public botocore service model. This caused the generated SDK to contain stale API definitions and shape fields that no longer match the public SageMaker API surface.

Fix

Replaced service-2.json with the latest public botocore service model, then re-ran codegen (python3 -m sagemaker.core.tools.codegen) to regenerate all downstream files.

Files regenerated by codegen:

File Effect
src/sagemaker/core/resources.py Updated resource classes and fields to match the current public API surface
resource_plan.csv Updated resource plan entries
src/sagemaker/core/config_schema.py Updated config schema definitions
src/sagemaker/core/utils/code_injection/shape_dag.py Updated shape dependency graph
src/sagemaker/core/tools/api_coverage.json Updated API coverage numbers (SupportedAPIs: 361→387, UnsupportedAPIs: 6→18)

Additional changes:

File What and Why
src/sagemaker/core/shapes/shapes.py Copied from the regenerated top-level shapes.py to shapes/shapes.py. Python resolves from sagemaker.core.shapes import * to the shapes/ package, so this copy must stay in sync.
src/sagemaker/core/resources.py (L30878) Fixed a pre-existing codegen bug: the TrainingJob.wait() method had an if block indented at 16 spaces instead of 8, causing SyntaxError. Manually dedented to the correct level.
~43 other files (various .py and test files) Code formatting only (whitespace, line wrapping) produced by black -l 100 . as the final codegen step. No functional changes.

Follow-up Commits

These commits fix CI failures and runtime issues discovered after the initial model refresh.

Commit File(s) What & Why
f252f4da sagemaker-train, sagemaker-mlops, sagemaker-core codegen tools, shapes.py, resources.py Removed references to shapes/fields that no longer exist in the updated model (enable_ffm, AddOnlineStoreReplicaAction). Added IntPipeVar support and REQUIRED_TO_OPTIONAL_OVERRIDES to codegen, then regenerated.
ae707dc sagemaker-core/.../resources.py Added Session = Boto3Session alias to fix NameError.
30c4c0c sagemaker-core/.../shapes/shapes.py Synced shapes/shapes.py package copy with updated top-level shapes.py.
7aac55c sagemaker-mlops/.../test_iceberg_properties.py Replaced removed description= param with feature_additions=[] in test calls.

Replace the internal service-2.json (502 operations, including 122 internal-only operations) with the public botocore service model (396 operations). Regenerate resources.py, shapes.py, resource_plan.csv, and related files from the public model to remove all leaked internal APIs, fields, and shapes.

This addresses the security issue where internal-only API operations (e.g.CreateTrainingJobInternal), internal fields on public APIs (e.g.UpstreamPlatformConfig, FasCredentials on CreateTrainingJob), and the internalservice model file itself were publicly exposed on GitHub and PyPI sincesagemaker-core >= 2.1.0 / >= 1.0.70 (Dec 3, 2025).

Ticket: P422086537

X-AI-Prompt: remove internal API leak from sagemaker-core
X-AI-Tool: kiro-cli
…aker-core

Fix upstream package breakages after removing internal-only fields/shapes
from sagemaker-core public SDK (PR aws#5800).

Changes:
- sagemaker-train: remove enable_ffm param from _create_input_channels()
  in finetune_utils.py (internal-only field, never used at runtime)
- sagemaker-mlops: remove dead import of AddOnlineStoreReplicaAction
  from feature_group_manager.py (shape only existed in internal model)
- sagemaker-core/tools: add PIPE_VAR_OVERRIDES for ResourceConfig to
  support ParameterInteger as instance_count/volume_size/keep_alive
- sagemaker-core/tools: add REQUIRED_TO_OPTIONAL_OVERRIDES for
  ModelPackage and ModelPackageSecurityConfig required fields
- sagemaker-core/tools: add IntPipeVar to PYTHON_TYPES_TO_BASIC_JSON_TYPES
  and config schema generation to fix codegen KeyError
- Regenerate shapes.py and resources.py with updated codegen

X-AI-Prompt: fix CI failures from internal API removal in upstream packages
X-AI-Tool: kiro-cli
Remove extra whitespace on blank line 30478 that caused Python to
misparse the subsequent code block, breaking all imports of
sagemaker.core.resources.

X-AI-Prompt: fix IndentationError in resources.py
X-AI-Tool: kiro-cli
…lict

The public botocore service model contains a StartSession API, which
caused codegen to generate an empty `class Session(Base)` Pydantic
model in resources.py. This shadowed the `from boto3.session import
Session` import, making Pydantic reject the actual Session objects
passed to TrainingJob.create() and other resource methods.

Added "Session" to EXCLUDED_RESOURCES in resources_extractor.py so
it is no longer discovered as a resource. Re-ran codegen to regenerate
downstream files.

X-AI-Prompt: Exclude Session from codegen resource discovery
X-AI-Tool: kiro-cli
},
# Override default instance type; the model's default
# (ml.p3.2xlarge) is deprecated.
"compute": Compute(instance_type="ml.g5.xlarge"),

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.

Why are we making this change ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a by-the-way integ-test fixing not corresponding to this issue. Confirmed with Zhaoqi.

input_mode=input_mode,
enable_ffm=enable_ffm,
)
input_mode=input_mode

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.

Why are we removing this ?

@lucasjia-aws lucasjia-aws Apr 29, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After replacing service-2.json, enable_ffm no longer exist in shapes.py, need to remove, also it is a dead call actually, safe to remove.

@lucasjia-aws lucasjia-aws changed the title fix: remove internal-only APIs and fields from sagemaker-core public SDK fix: refresh sagemaker-core service model and regenerate SDK Apr 29, 2026
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.

2 participants