fix(core): remove four dead duplicate definitions shadowed by a later copy - #6267
Open
Anai-Guo wants to merge 1 commit into
Open
fix(core): remove four dead duplicate definitions shadowed by a later copy#6267Anai-Guo wants to merge 1 commit into
Anai-Guo wants to merge 1 commit into
Conversation
… copy
Each of these names is bound twice at the same scope, so the first definition is
unreachable - Python simply rebinds the name and the earlier object is
discarded:
* `sagemaker/core/utils/utils.py` - `snake_to_pascal` is defined twice. The
first copy predates `SPECIAL_SNAKE_TO_PASCAL_MAPPINGS` and does not consult
it, so it would mis-convert e.g. `volume_size_in_g_b`. It never runs: the
second definition (which does consult the mapping) is the one every caller
gets.
* `sagemaker/core/training/configs.py` - `OutputDataConfig` is declared twice
with identical fields; only the docstrings differ. The later, more accurate
docstring is the one that survives.
* `sagemaker/core/remote_function/job.py` - `_get_initial_job_state` is defined
twice, byte for byte.
* `sagemaker/serve/model_builder_utils.py` -
`_ModelBuilderUtils._extract_speculative_draft_model_provider` is defined
twice in the same class body, byte for byte.
In every case this removes the dead copy and keeps the one that was already
live, so the change is a no-op at runtime.
Verified by comparing `ast.dump` of the final binding for every module-level and
class-level name before and after: identical in all four files. Also confirmed
no module-level code references any of these names between the two definitions
(which would otherwise bind the earlier object at import time).
Smoke-checked at runtime:
`snake_to_pascal("volume_size_in_g_b") == "VolumeSizeInGB"` and
`OutputDataConfig.model_fields == {s3_output_path, kms_key_id, compression_type}`,
and `pytest sagemaker-core/tests/unit/utils` stays at 25 passed.
Signed-off-by: Anai-Guo <antai12232931@outlook.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Anai-Guo
requested a deployment
to
manual-approval
September 12, 2026 16:14 — with
GitHub Actions
Waiting
Anai-Guo
requested a deployment
to
manual-approval
September 12, 2026 16:14 — with
GitHub Actions
Waiting
Anai-Guo
requested a deployment
to
manual-approval
September 12, 2026 16:14 — with
GitHub Actions
Waiting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
None (found by auditing duplicate definitions at the same scope).
Description
Four names in the shipped source are bound twice at the same scope. Python simply rebinds the name, so the first definition is unreachable dead code:
sagemaker-core/.../utils/utils.pysnake_to_pascalSPECIAL_SNAKE_TO_PASCAL_MAPPINGSand does not consult itsagemaker-core/.../training/configs.pyOutputDataConfigsagemaker-core/.../remote_function/job.py_get_initial_job_statesagemaker-serve/.../model_builder_utils.py_ModelBuilderUtils._extract_speculative_draft_model_providerThe
snake_to_pascalpair is the interesting one: the dead first copy would mis-convert names covered by the special-case mapping (e.g.volume_size_in_g_b→VolumeSizeInGbinstead ofVolumeSizeInGB). It never runs — every caller resolves the second, mapping-aware definition — but leaving it there invites someone to "fix" the wrong one.In every case this PR deletes the dead copy and keeps the one that was already live, so it is a no-op at runtime (
+0 / −71).Testing done
ast.dumpof the final binding of every module-level and class-level name before and after the edit — identical in all four files.snake_to_pascal("volume_size_in_g_b") == "VolumeSizeInGB"✅ (special mapping still honoured)snake_to_pascal("output_data_config") == "OutputDataConfig"✅OutputDataConfig.model_fields == {s3_output_path, kms_key_id, compression_type}✅pytest sagemaker-core/tests/unit/utils— 25 passed, unchanged.Merge Checklist
Tests
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
🤖 Generated with Claude Code