Skip to content

fix: replace implicit s3fs usage with explicit S3Downloader in feature_utils - #6596

Open
pravali96 wants to merge 4 commits into
aws:masterfrom
pravali96:fix/replace-s3fs-with-s3downloader
Open

pravali96 wants to merge 4 commits into
aws:masterfrom
pravali96:fix/replace-s3fs-with-s3downloader

Conversation

@pravali96

@pravali96 pravali96 commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Issue #, if available:
s3fs needs aiobotocore, which pins botocore<1.43.118, while this package requires botocore>=1.43.127.
pip resolves that by backtracking to s3fs 0.4.2 (2020) — fsspec warns on load that it's "very old and known to cause severe performance issues." The dependency was forcing a six-year-old package into every install.

Description of changes:
Removes s3fs from sagemaker-mlops/pyproject.toml and keeps s3:// input working exactly as before — no new feature, no promotion:

  • s3:// still works. Now via S3Downloader/boto3 (already a hard dependency) instead of s3fs.
  • Gzipped objects still work. s3://b/data.csv.gz kept parsing because compression is inferred from the key. Without this it raised UnicodeDecodeError — the one real CX break, now fixed and tested.
  • Caller's credentials are used, not the default chain.
  • Docstring just notes the path may be an s3:// URI. Function stays unexported and out of the docs site, as before.

Net diff across three commits: pyproject.toml −1, feature_utils.py +41/−13, test_feature_utils.py +158.

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

…e_utils

- Add explicit S3 path detection using dataframe_or_path.startswith('s3://')
- Use S3Downloader.read_bytes() with io.BytesIO() wrapper for S3 paths
- Remove s3fs dependency from sagemaker-mlops pyproject.toml
- Preserves existing functionality for DataFrames and local file paths

Testing:
- All 43 existing unit tests pass - no regressions
- Added test_s3fs_equivalence.py proving S3Downloader.read_bytes produces
  IDENTICAL results to s3fs for the same S3 input
- Equivalence test validates: same DataFrame shape, columns, dtypes, and values
- See EQUIVALENCE_PROOF.md for detailed analysis
Follow-up to the s3fs removal in prepare_fg_from_dataframe_or_file.

Three issues with the previous commit:

1. The S3 read dropped the caller's credentials. S3Downloader.read_bytes was
   called without a session, so read_bytes fell back to `sagemaker_session or
   Session()` and built a fresh default-credential-chain session, while the
   FeatureGroup was built from the caller's session resolved ~40 lines later.
   A caller passing an explicit cross-account session read S3 as the ambient
   identity. Session resolution now happens before any data is read and is
   passed through to read_bytes.

2. pathlib.Path inputs were rejected. The signature accepts
   Union[str, Path, DataFrame] but the branch tested only `str`, so a Path fell
   through to the "Invalid type" error. The branch now accepts both and the
   error message lists the real accepted types.

3. EQUIVALENCE_PROOF.md and test_s3fs_equivalence.py were committed to the
   repository root. The script was a standalone main() that manipulated
   sys.path and asserted pd.read_csv(BytesIO(x)) == pd.read_csv(BytesIO(x)) --
   the same expression on both sides, so it exercised neither s3fs nor the new
   branch. Both files are removed and replaced with real unit tests.

Tests added to the existing
sagemaker-mlops/tests/unit/sagemaker/mlops/feature_store/test_feature_utils.py:

- an s3:// path is fetched via S3Downloader and the downloaded bytes (not the
  URI) are what reach load_feature_definitions
- the caller's session is threaded into read_bytes, for both an explicit
  session and one resolved from role + region
- a local path never touches S3Downloader
- pathlib.Path is accepted

Three of the four fail against the previous commit's source and pass against
this one. Full file: 47 passed, 24 failed; the 24 failures are identical at
5fe6647 (before any s3fs work), so they are pre-existing and unrelated.

Note for reviewers: dropping s3fs is a behavioural change for callers that
passed an s3:// path together with fsspec `storage_options` in **kwargs --
those kwargs were previously forwarded to s3fs and will now raise against a
BytesIO buffer.
---
X-AI-Prompt: Remove s3fs from the SageMaker SDK; investigate why it was introduced and what used it, then fix the session-threading and Path gaps in PR aws#6596 and replace the stray proof files with real unit tests.
X-AI-Tool: Claude Code
Preserves existing behaviour for s3:// input after the s3fs removal.

pandas infers compression from the file extension only when read_csv is given
a path. The s3:// branch hands it an in-memory buffer instead, which has no
filename, so inference was lost and a gzipped object failed:

    pd.read_csv(io.BytesIO(gzip.compress(csv)))
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1

s3://bucket/data.csv.gz worked before this change (pandas saw the URL and
inferred gzip from the suffix), so this would have been a silent regression.
Compression is now inferred from the S3 key with pandas' own
infer_compression, covering .gz/.bz2/.zip/.xz/.zst. An explicit compression=
from the caller still wins.

The docstring now mentions that the path may be an s3:// URI -- stating what
already worked, not promoting S3 input to a documented feature; the function
remains unexported and absent from the docs site, as before.

Tests (added to the existing test_feature_utils.py):
- a gzipped S3 object parses; fails without the inference, verified
- an explicit compression= kwarg is not overridden by inference

Class: 21 passed. File: 49 passed, 24 failed -- those 24 are a local
config.yaml missing SchemaVersion (jsonschema validation in
sagemaker/core/config/config.py), identical on master and unrelated to s3fs.

Known difference, not addressed here: read_bytes buffers the whole object
before parsing where s3fs streamed, so peak memory is higher on large CSVs
and chunksize=/iterator= no longer stream the download.
---
X-AI-Prompt: Remove s3fs from sagemaker-mlops without changing the customer experience; keep s3:// input working as before and don't promote S3 to a first-class feature.
X-AI-Tool: Claude Code
storage_options configures the fsspec filesystem pandas would have opened an
s3:// URI with -- for S3 that was s3fs.S3FileSystem(**storage_options), giving
callers anon, requester_pays, client_kwargs/endpoint_url and friends.

The object is now fetched with S3Downloader before parsing, so read_csv
receives a buffer and rejects the argument outright:

    ValueError: storage_options passed with file object or non-fsspec file path

Nothing in this package passes storage_options; it can only arrive from a
caller, since **kwargs are forwarded to read_csv and the docstring points at
the pandas read_csv reference. Surfacing a pandas error about file objects is
not useful, so the argument is dropped with a warning via core's existing
pop_out_unused_kwarg helper ("storage_options supplied in kwargs will be
ignored") and the read proceeds on the session's credentials.

Only the s3:// branch drops it -- for a local path storage_options remains
pandas' business and is still forwarded.

Note this does remove capability rather than relocate it: anon,
requester_pays and a custom endpoint_url have no S3Downloader equivalent.
Callers needing specific credentials should pass a configured session=.

Tests:
- storage_options on an s3:// path warns and the read still succeeds; fails
  with the pandas ValueError if the pop is removed, verified
- storage_options on a local path still reaches read_csv untouched

Class: 23 passed. File: 51 passed, 24 failed -- the 24 are a local
config.yaml missing SchemaVersion, identical on master and unrelated.

Re-verified end to end against a dev account (us-west-2): s3:// plain and
gzipped reads on both a default and a non-default bucket, plus local path,
Path and DataFrame inputs. 8/8.
---
X-AI-Prompt: Follow the SDK's own convention for a no-longer-applicable kwarg -- warn and drop storage_options on the s3:// path instead of letting pandas raise, with tests.
X-AI-Tool: Claude Code
@pravali96
pravali96 deployed to manual-approval November 19, 2026 23:03 — with GitHub Actions Active
@pravali96
pravali96 marked this pull request as ready for review November 19, 2026 23:23

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 AI code review

This PR removes the s3fs dependency from sagemaker-mlops and reworks prepare_fg_from_dataframe_or_file to read s3:// CSVs via the already-present S3Downloader.read_bytes (using the caller's session), inferring compression from the key so gzipped objects keep working. It also accepts pathlib.Path and moves session resolution before the data read. The change is well-scoped, backward compatible, and comes with thorough unit tests. Imports (S3Downloader, pop_out_unused_kwarg, read_bytes) all resolve against the base checkout. Only a minor concern about relying on a semi-private pandas API.

Reviewed commit 8c7381e. Automated review; verify before acting.

import pandas
import pandas as pd
from pandas import DataFrame, Series, read_csv
from pandas.io.common import infer_compression

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Low: infer_compression is imported from pandas.io.common, which is not part of pandas' public API and can change signature or location across pandas releases. Given pandas<3.0 has no lower bound here, this is a small maintenance risk. Consider either pinning behavior with a small local mapping of extension->compression for the handful of suffixes you care about (.gz/.bz2/.zip/.xz/.zst), or at least guarding the import so a future pandas change degrades gracefully to compression='infer'.

lucasjia-aws pushed a commit that referenced this pull request Nov 29, 2026
…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.
@lucasjia-aws

Copy link
Copy Markdown
Collaborator

squashed into #6606

@lucasjia-aws lucasjia-aws mentioned this pull request Nov 29, 2026
lucasjia-aws added a commit that referenced this pull request Nov 30, 2026
* feat: Release the data-preparation feature branch onto master

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

* chore: Bump versions to 3.31.0 for the Verse GA release (#2546)

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

* fix(prompt-opt): Stop adding a resource policy to the grader Lambda (#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

* feature: leaderboard API launch model (#2553)

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.

* chore: GenAIEvaluator GA schema, HPO eval tag and Data Prep fix (#2552)

* 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>

* test(train): put sagemaker-mlops on the unit-test PYTHONPATH (#2558)

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>

* fix(core): tolerate server-added fields on JumpStart config entries (#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>

* fix: Phase 0 train-unit isolation + codestyle (black/flake8) for 3.31.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>

* fix(core): bundle tools data files; guard the overrides-vs-sample test (#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>

* rebase to master/head (#2563)

* 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>

* docs: fix the 3.31.0 CHANGELOG entries for #2168 and #2533 (#2564)

* chore(train): remove unused legacy endpoint-name prefix in APO target_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.

* fix(mlops): drop s3fs dependency, read s3:// via S3Downloader in feature_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.

* chore(train): generalize internal project references in APO comments 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.

---------

Co-authored-by: AMARJEET J <jamjee@amazon.com>
Co-authored-by: Kalyani Nikure <110067132+knikure@users.noreply.github.com>
Co-authored-by: papriwal <papriwal@amazon.com>
Co-authored-by: Lucky <soklim@amazon.com>
Co-authored-by: Zuoyuan Huang <david.hzy97@gmail.com>
Co-authored-by: Zuoyuan Huang <zuoyuan@amazon.com>
Co-authored-by: Mohamed Zeidan <81834882+mohamedzeidan2021@users.noreply.github.com>
Co-authored-by: Mohamed Zeidan <zeidmo@amazon.com>
Co-authored-by: rsareddy0329 <rsareddy0329@gmail.com>
Co-authored-by: rsareddy <rsareddy@amazon.com>
Co-authored-by: Pravali Uppugunduri <upravali@amazon.com>

This branch was previously deployed

1 inactive deployment
manual-approval — 8c7381ec Deployed Nov 19, 2026 by pravali96 via wait-for-approval #908
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