Repository navigation
Release 3.31.0 - #6606
Release 3.31.0#6606
Conversation
Squash of aws/sagemaker-python-sdk-staging master-data-preparation (a8240205b, 107 commits since Release 3.24.0) onto public master 5fe6647 (v3.30.0 + 2). Merge decisions, by bucket: - VERSION / CHANGELOG / pyproject pins: public (3.30.0 line) kept; the branch's optional-dependency and marker additions survive. - sagemaker-core service model (sample/sagemaker/2017-07-24/service-2.json): public botocore snapshot plus the branch's 14 pre-release operations (Leaderboard/Candidate, ModelMonitorConfig/Execution) and 116 shapes, and TracingConfig on CreateEndpointConfig / DescribeEndpoint(Config). resources.py, shapes.py, shape_dag.py, config_schema.py, resource_plan.csv and api_coverage.json regenerated with codegen.py from that model. - resources_codegen.py: union of public's identifier_preferred (managed pipelines) and the branch's identifier_aliases / resource mixins. - ai_registry/data_preparer: public's package (#6585, from the master-data-preparation-r2riv branch) kept as-is. The branch's GapAnalysis / DataPreparer.analyze() and its @experimental marker are NOT in this commit; see the release handoff for the replay patch. - ai_registry dataset.py / dataset_utils.py / air_hub.py and their tests: public (superset of the branch's state). - ModelTrainer.train(): returns the TrainingJob for managed jobs (branch) and the artifact path for local mode (public, #6556). Public's training_job_name handling (#5776, #6299) kept over the branch's PipelineSession pop. - Staging-only CI workflows (preview-*, pr-checks-factory, sagemaker-loop jobs in pr-checks-master) dropped; .github matches public except copilot-instructions.md. X-AI-Prompt: Rebase the Verse staging feature branch onto public master for the 11/30 release X-AI-Tool: kiro-cli
Lockstep bump of the five distributions and their intra-SDK pins, the same shape as the 3.30.0 release commit (8ae92a5) without CHANGELOG entries: sagemaker 3.31.0, sagemaker-core 2.31.0, sagemaker-train, sagemaker-serve and sagemaker-mlops 1.31.0. The preview publisher derives X.Y.(Z+1).devN from VERSION, so the master-verse-riv channel now publishes 3.31.1.devN instead of 3.30.1.devN, which is what the Verse sandbox image bundles for GA. X-AI-Prompt: Bump VERSION to 3.31.0 on master-verse-riv and the other packages' minor versions, then re-publish X-AI-Tool: kiro-cli
…2549) Advanced Prompt Optimization invokes a custom Lambda grader with the caller's own permissions (a forwarded access session using the caller's lambda:InvokeFunction and lambda:GetFunction), not as the bedrock.amazonaws.com service principal. Verified live in the dev account: under a role carrying only the SageMaker AI managed policies, an APO job invoked a grader that had no resource policy at all. The AddPermission call BedrockLambdaDeployer made after every deploy ("bedrock.amazonaws.com may invoke, SourceAccount = this account") was therefore never consulted, and the next version of AmazonSageMakerAIPromptOptimizationAccess drops lambda:AddPermission, lambda:RemovePermission and lambda:GetPolicy (IAM review of NAPS 26772, P569267487). Under that policy the call would be denied, so it goes. No behavior change for graders: the execution role still gets InvokeFunction and GetFunction on *SageMaker* function names from AmazonSageMakerModelCustomizationCoreAccess, which is the path APO uses. X-AI-Prompt: Remove the grader Lambda resource-policy grant from the SDK now that APO is verified to invoke the grader with the caller's permissions X-AI-Tool: kiro-cli
Splice the leaderboard operations from their launch model and regenerate sagemaker-core: - ListLeaderboards: Leaderboard.get_all() pages through ListLeaderboards and reads each leaderboard back with GetLeaderboard, like Candidate.get_all(). New LeaderboardSummary shape (arn, name, creation_time, last_modified_time). - DeleteLeaderboard declares ConflictException, raised when the leaderboard still has candidates. - AddCandidate declares ResourceLimitExceeded for the candidates-per- leaderboard limit. - The ListCandidates response returns only Items and NextToken. Candidate.get_all() is unaffected: it takes each candidate's leaderboard_arn from the request. - Input patterns follow existing SageMaker APIs. DatasetArn is a hub-content DataSet ARN or an s3:// URI, EvalCriteriaArn a hub-content JsonDoc ARN, and PromptTemplateArn a hub-content or Bedrock prompt ARN, each with its own shape in place of the shared LeaderboardCustomerArn. Display names, labels and references reject control characters, SourceId is a run id and SourceUrl must be https. botocore does not check patterns; the service enforces them. Missing resources stay SageMaker's shared ResourceNotFound. Unrelated operations and shapes are unchanged, a second codegen run produces no diff, and api_coverage.json counts the new supported API. Tests: Leaderboard.get_all paging, read-back and delete, ConflictException on delete, and model tests for the declared errors, list response shapes, ARN shapes and patterns. Fixtures and the integration test use ARNs that match the new patterns. get_all is added to Leaderboard in resource_test_config.json.
* fix(train): tag HPO evaluation jobs with the project id (#2530) When a sweep has a project_id, each trial's evaluation job now carries the sagemaker:project-id tag, as the trial's fine-tune already does. (cherry picked from commit 5f9e35cac4b340fc8322e1b541c468a91d43ff73) * fix(data_preparer): default only one output-location field The SDG 2.0.0 schema declares both OutputDataConfig.S3OutputPath and the legacy OutputS3Uri as optional. The defaults walk filled each one from the well-known fallback, so a generate() call that set S3OutputPath also sent a defaulted OutputS3Uri pointing at the SDK default bucket. Fill only one spelling: S3OutputPath wherever the schema declares it, and OutputS3Uri only on legacy v1 schemas that lack it. A value the caller sets under either spelling is left alone and the other is not added. (cherry picked from commit 580c301c3ce9601f9246227652117c57cfa9894b) * fix(data_preparer): read SDG progress location from S3OutputPath SDG progress tracking read only OutputDataConfig.OutputS3Uri. With the defaults walk filling only S3OutputPath on the 2.0.0 schema, a generate() call had no output location for progress, so the "Samples: X/Y" line was not shown. Read S3OutputPath first and fall back to OutputS3Uri for v1 pins. (cherry picked from commit c41d57a45e03d8190a294cb985e7bec0fa777872) * feat(evaluate): update GenAIEvaluator CreateJob to the GA GenAIEvaluation 1.0.0 schema, with HPO and prompt optimization (#2533) * feat(evaluate): name the offline dataset in the evaluation criteria The GenAIEvaluation/1.0.0 job document has no input dataset for a batch job: the EvaluationCriteria names it, as PublicBenchmark.Dataset or CustomBenchmark.Dataset (S3Uri or DatasetArn). The document also has no SampleRecordCount or OutputDataConfig.KmsKeyArn. GenAIEvaluator: - Drop dataset, sample_record_count and kms_key_arn, with their validators and constants. build_config() sends EvaluationCandidate, EvaluationMethod and OutputDataConfig only. - Document that evaluation_criteria names the dataset, and update the example. - Drop the stale SAGEMAKER_LEGO notes: the schema no longer lists it, and its default provider is BEDROCK. HyperparameterOptimizer: - Drop dataset, sample_record_count and kms_key_arn from HyperparameterOptimizationEvalConfig and the job config's objective.eval block. - Drop eval_dataset and eval_sample_record_count from the frozen resume keys: the version-qualified criteria ARN already pins the dataset. Tests: remove the tests of the dropped fields, and stop passing a dataset in the unit and integ tests. The integ tests now take only the criteria ARNs; each criteria names its dataset. Prompt optimization is not changed here. It still passes dataset and sample_record_count to GenAIEvaluator and sends S3DataSource from its own GenAIEvaluationJob, and moves to criteria-named datasets in a follow-up. * feat(prompt-opt): run each held-out eval on a per-run criteria copy (GA GenAIEvaluation 1.0.0) The GA GenAIEvaluation/1.0.0 job takes no dataset: its EvaluationCriteria names it (CustomBenchmark.Dataset). Prompt optimization scores each prompt on its own rendered held-out file, which the caller's criteria cannot name, and still passed dataset and sample_record_count to GenAIEvaluator, which ignored them. - start() imports one copy of the caller's criteria per eval, <criteria>-<run id>-<initial|optimized>/1.0.0 in the same hub, whose CustomBenchmark.Dataset.S3Uri is that eval's held-out file. The file's key is fixed per run, so the copy is created before Prepare/Finalize write it. The copies are kept after the run. The criteria must be an EvaluationCriteria v0.1.0 CustomBenchmark. - The eval steps run that copy, and pass no dataset or sample_record_count. - eval_sample_record_count keeps its 1-50 check at graph build, and the steps write only that many held-out rows. - GenAIEvaluationJob drops dataset_s3uri, sample_record_count and EvaluationDataset. - render_and_upload and the copies share one URI helper (S3Layout.eval_dataset_uri). - CONTRACTS.md: the criteria requirement, and the DescribeHubContent and ImportHubContent calls start() makes as the caller. * feat(prompt-opt): send eval_sample_record_count as SamplingConfig.MaxRecords The GA GenAIEvaluation/1.0.0 schema bounds how many records a job scores with a top-level SamplingConfig. Prompt optimization sends its eval_sample_record_count there, instead of writing fewer held-out rows: - The eval steps run a GenAIEvaluator subclass that adds SamplingConfig {"MaxRecords": n} when eval_sample_record_count is set. GenAIEvaluator's own API is unchanged. The 1-50 check stays. - write_eval_dataset writes every held-out row again. - GenAIEvaluationJob takes sample_record_count again and sends it as SamplingConfig.MaxRecords. * feat(evaluate): add sampling_config to GenAIEvaluator The GA GenAIEvaluation/1.0.0 schema has a top-level SamplingConfig (Percentage, MaxRecords, Strategy). GenAIEvaluator takes it as sampling_config, in the API's shape like rag_configuration, checks it against the schema (known keys, at least one of Percentage or MaxRecords, Percentage in (0, 1], MaxRecords 1-5000, Strategy Deterministic) and sends it as SamplingConfig. - HyperparameterOptimizationEvalConfig passes sampling_config through to each trial's evaluation, like the other GenAIEvaluator options. - Prompt optimization sends eval_sample_record_count through it as {"MaxRecords": n}, in place of its private GenAIEvaluator subclass. * feat(evaluate): follow schema revision 5, where the job's dataset overrides the criteria's GenAIEvaluation/1.0.0 revision 5 (CR-325044958) brings back the job's EvaluationDataset (S3DataSource, DatasetSource or CloudWatchLogsSource) as an optional field that overrides the dataset the criteria names, and makes SamplingConfig.Percentage a percent (above 0.01, at most 100). SampleRecordCount and OutputDataConfig.KmsKeyArn stay removed. GenAIEvaluator: - dataset is back, optional. When set it is sent as EvaluationDataset.S3DataSource; unset, the job uses the criteria's dataset. - sampling_config.Percentage is checked against the new range. HyperparameterOptimizer: - dataset is back as an optional evaluation setting, passed to each trial and frozen for resume. Prompt optimization: - Drop the per-run criteria copies (eval_criteria.py, the import at start(), the ImportHubContent call, the v0.1.0 CustomBenchmark requirement and the CONTRACTS.md notes). Each eval job gets its prompt's held-out file as its dataset again, as on master-data-preparation. - Its only change now: eval_sample_record_count (still 1-50) and GenAIEvaluationJob.sample_record_count are sent as SamplingConfig.MaxRecords instead of SampleRecordCount. Tests and integ tests follow: datasets are passed again, and the sample-size inputs use sampling_config. --------- Co-authored-by: Zuoyuan Huang <zuoyuan@amazon.com> (cherry picked from commit fbc2e53d61a414a8abfd8be8fb277dd39f3773be) --------- Co-authored-by: Lucky <soklim@amazon.com> Co-authored-by: Zuoyuan Huang <david.hzy97@gmail.com> Co-authored-by: Zuoyuan Huang <zuoyuan@amazon.com>
The APO, GenAIEvaluator and air_hub unit tests import sagemaker.mlops to build real pipeline objects (JobStep, retry policies). sagemaker-mlops depends on sagemaker-train, so it cannot be a pip test dependency; expose the sibling package sources on PYTHONPATH instead, the same approach the pylint env already uses. Fixes the train unit build failing with "ModuleNotFoundError: No module named 'sagemaker.mlops'" (9 modules erroring at collection). Verified: the 9 modules now run, 455 passed. Co-authored-by: Mohamed Zeidan <zeidmo@amazon.com>
…2560) The live JumpStart hub now returns a QualityBenchmarks field (BBH scores) on each inference/training config entry. ConfigSchemaModel inherits BaseConfig's extra="forbid", so parsing a HubContentDocument raises ValidationError (extra_forbidden) and fails test_all_hub_content_documents and test_search_public_hub_models_all_args on any branch (reads live hub). Set extra="ignore" on ConfigSchemaModel, matching HubContentDocument's own policy, so unknown server-added fields are tolerated. Co-authored-by: Mohamed Zeidan <zeidmo@amazon.com>
….0 (#2561)
* test(train): restore os.environ between trainer unit tests
The HPO optimizer and some tests set process env vars (AWS_ENDPOINT_URL_SAGEMAKER,
AWS_REGION) directly on os.environ. The cleanup fixture only existed in
test_optimize_request.py, so other HPO tests (e.g. test_telemetry.py) leaked those
vars into later tests in the same xdist worker. That made 4 tests fail only in the
full parallel run (pass in isolation):
- prompt_optimization/test_run.py::test_from_arn_takes_the_plane_from_the_session
- training_session/test_clients.py::test_control_plane_client_{honours_a_fips_configuration,
targets_the_regional_production_endpoint,uses_the_regions_own_dns_suffix}
Add an autouse fixture in tests/unit/train/conftest.py that snapshots and restores
os.environ around every trainer unit test. Verified: the reproduced sequence goes
from 4 failed / 128 passed to 132 passed.
* style: black format and flake8 fixes for the 3.31.0 (Verse) code
Run black 26.3.1 across core/train/serve/mlops and resolve the flake8 findings
the codestyle-doc lane reported:
- core: remove a duplicate "DataPreparer" key in config_schema.py (F601)
- train: drop unused imports (base_evaluator Session + TYPE_CHECKING block,
evaluation.py statistics / rows_to_apo_samples, test_genai_evaluator
ExecutionVariables); remove an exact-duplicate test block in test_air_hub.py
that shadowed 3 tests (F811); silence F811 on a helper param in
test_model_package.py
- mlops: drop an unused Join import in steps.py
---------
Co-authored-by: Mohamed Zeidan <zeidmo@amazon.com>
#2562) The new splice tool's data files (service_model_doc_overrides.json and the other tools/*.json) were not listed in package-data, so an installed package raised FileNotFoundError and failed tests/unit/tools/test_splice_service_model.py::test_committed_overrides_file_names_only_entries_of_the_sample_model in the core unit build. Add tools/*.json and tools/model_card/*.json to package-data. That same test also reads the sample service model, which lives outside the package (sagemaker-core/sample/, only present in a source checkout). Skip the test when the sample file is absent -- it is a source-tree guard that the committed overrides agree with the committed sample, not a runtime test. Verified: the built wheel now contains sagemaker/core/tools/service_model_doc_overrides.json, and the test passes in a source checkout. Co-authored-by: Mohamed Zeidan <zeidmo@amazon.com>
* fix(telemetry): resolve SDK version dynamically in user agent (#6546) SDK_VERSION in sagemaker-core/src/sagemaker/core/user_agent.py was hardcoded to "3.0", so every V3 install reported x-sdkVersion=3.0 regardless of the installed release. This blanked out the "Users by SDK Version" telemetry dashboard for all newer versions (core, serve, and train telemetry all import this one constant). Restore the dynamic resolution V2 used (importlib_metadata.version): prefer the "sagemaker" meta-package version, fall back to "sagemaker-core" for standalone installs, and keep a static "3.0" fallback so user-agent/telemetry construction never raises. Add tests/unit/test_user_agent.py, which the module previously lacked, including a regression guard against re-hardcoding the version. Co-authored-by: rsareddy <rsareddy@amazon.com> * Release 3.31.0 --------- Co-authored-by: rsareddy0329 <rsareddy0329@gmail.com> Co-authored-by: rsareddy <rsareddy@amazon.com>
There was a problem hiding this comment.
🤖 AI code review
This is the 3.31.0 release PR: it bumps versions/CHANGELOGs, vendors an updated service-2.json and generated resources.py (Leaderboard/Candidate/ModelMonitorConfig/TracingConfig), adds docs, and introduces hand-written modules (experimental.py, endpoint.py, hub catalog/content caching) plus format_tags tag-matching improvements in common_utils.py. The bulk is generated/vendored and follows established patterns. The only concrete issue I found in the hand-written code is a duplicated module docstring in config_schema.py; everything else I reviewed looks consistent. I did not exhaustively review every generated hunk given the diff size.
Reviewed commit 00304be. Automated review; verify before acting.
| @@ -1,5 +1,7 @@ | |||
| """JSON schema definition for the SageMaker Python SDK configuration file.""" | |||
|
|
|||
| """JSON schema definition for the SageMaker Python SDK configuration file.""" | |||
There was a problem hiding this comment.
🟡 Low: The module docstring is now duplicated: the same """JSON schema definition for the SageMaker Python SDK configuration file.""" string appears twice back-to-back. The second copy is a no-op string literal, not the module docstring, and looks like an accidental paste. Remove the duplicate line.
…_deploy The prompt_optimization target_deploy module recognized a legacy endpoint-name prefix alongside the current "po-" prefix. No released endpoint uses the legacy name, so drop it. Naming (deploy_name) and cleanup (sweep_stale/delete_deployed) are unchanged for "po-" endpoints; the sweep unit test is updated to match.
There was a problem hiding this comment.
🤖 AI code review
This PR is the 3.31.0 release: version bumps, CHANGELOG/doc/migration.md updates, a regenerated sagemaker service model (Leaderboard, Candidate, ModelMonitorConfig, TracingConfig), regenerated resources.py, and hand-written modules (experimental.py, endpoint.py) plus format_tags tag-casing fixes. The hand-written logic (format_tags/_to_tag_dict/tag_exists, the @experimental decorators, and the EndpointMixin diagnostics) reads correctly, and the migration.md field names (enable_managed_spot_training on Compute, max_wait_time_in_seconds on StoppingCondition) match the real SDK. The only concrete issue I found is a duplicated module docstring introduced in config_schema.py.
Reviewed commit 08711a0. Automated review; verify before acting.
| @@ -1,5 +1,7 @@ | |||
| """JSON schema definition for the SageMaker Python SDK configuration file.""" | |||
|
|
|||
| """JSON schema definition for the SageMaker Python SDK configuration file.""" | |||
There was a problem hiding this comment.
🟡 Low: This adds a second, identical module docstring right after the existing one on line 1. Only the first string literal is treated as the module docstring; the second is a dead expression statement. Please remove the duplicate line.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #6606 +/- ##
==========================================
+ Coverage 76.52% 77.66% +1.14%
==========================================
Files 644 708 +64
Lines 82350 95055 +12705
==========================================
+ Hits 63016 73829 +10813
- Misses 19334 21226 +1892 🚀 New features to boost your workflow:
|
…ure_utils (#6596) s3fs pulls in aiobotocore, which caps botocore <1.43.118. sagemaker-mlops requires botocore>=1.43.127 (#6574, pipeline version aliases), so the conda-forge solver cannot build an environment. On PyPI, pip backtracks to s3fs 0.4.2 (2020) instead. This blocked sagemaker 3.30.0 on conda-forge. - Remove s3fs from sagemaker-mlops dependencies. - prepare_fg_from_dataframe_or_file reads s3:// CSVs with S3Downloader.read_bytes and the caller's session, not the default credential chain. - Infer compression from the S3 key, so .csv.gz and similar keep working. - Warn and drop storage_options on s3:// reads. - Accept pathlib.Path input. - Add unit tests for the s3:// path.
There was a problem hiding this comment.
🤖 AI code review
This is the v3.31.0 release PR: it bumps VERSION/CHANGELOG/pyproject across sub-packages, updates the generated service-2.json API model (Leaderboard, Candidate, ModelMonitorConfig, TracingConfig), adds hand-written core modules (experimental.py, endpoint.py, hub_catalog.py), refines format_tags/tag_exists/remove_tag_with_key tag handling, and adds docs. The version bumps follow the established release pattern (consistent core 2.31.0 / train·serve·mlops 1.31.0). The hand-written experimental and endpoint modules are carefully implemented. The only concrete defect I found is an accidentally duplicated module docstring in config_schema.py. The diff is very large and mostly generated model/resource code and docs, which were reviewed in their component PRs; I focused on hand-written changes visible in the diff.
Reviewed commit 8bd9b8b. Automated review; verify before acting.
| @@ -1,5 +1,7 @@ | |||
| """JSON schema definition for the SageMaker Python SDK configuration file.""" | |||
|
|
|||
| """JSON schema definition for the SageMaker Python SDK configuration file.""" | |||
There was a problem hiding this comment.
🟡 Low: The module docstring is now duplicated: line 1 already holds """JSON schema definition...""", and this hunk adds an identical string literal on line 3. The second literal is a no-op expression statement (only the first is treated as the module docstring) and looks like an accidental paste. Remove the duplicate line.
…and tests Reword internal skill/project references in prompt-optimization docstrings, comments and CONTRACTS, and rename endpoint-name test fixtures to the neutral po- prefix. The rename also restores is_deploy_name recognition, fixing test_pipeline_plane's delete-and-sweep assertion.
There was a problem hiding this comment.
🤖 AI code review
This is the 3.31.0 release PR: it bumps versions across sagemaker-python-sdk/sagemaker-core and inter-package constraints, updates CHANGELOGs, docs (experimental-API policy, hub catalog/search guidance, migration table), adds the generated Leaderboard/Candidate/ModelMonitorConfig/TracingConfig API models, and introduces hand-written helpers (experimental.py, endpoint.py) plus a format_tags/tag_exists/remove_tag_with_key tag-casing fix. The release mechanics follow the established pattern (version consistency across pyproject.toml/VERSION/CHANGELOG, per PR #6563). The hand-written changes I could inspect (tag normalization, endpoint diagnostics against the cached SageMakerClient) look correct. The only concrete issue I found is an accidental duplicate module docstring in config_schema.py.
Reviewed commit 0ad3cf8. Automated review; verify before acting.
| @@ -1,5 +1,7 @@ | |||
| """JSON schema definition for the SageMaker Python SDK configuration file.""" | |||
|
|
|||
| """JSON schema definition for the SageMaker Python SDK configuration file.""" | |||
There was a problem hiding this comment.
🟡 Low: The module docstring is duplicated: the same """JSON schema definition for the SageMaker Python SDK configuration file.""" now appears on line 1 (the real docstring) and again on line 3. The second one is a no-op string statement, not a docstring, and looks like an accidental paste. Remove the duplicate (lines 2-3).
SageMaker Python SDK v3.31.0
New Features
Bug Fixes
commanddefault. #2404, documentation: Add import statement in Batch Transform Overview doc #2406, Error while training on SageMaker #2408, fix: default value removed if zero for integer param #2409, fix: deprecate tag logic on Association #2552)Dependencies
Tests