-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
component: pysdk-teamRelated to SageMaker Python SDK Core IssuesRelated to SageMaker Python SDK Core Issuescomponent: trainingRelates to the SageMaker Training PlatformRelates to the SageMaker Training Platformtype: documentation
Description
What did you find confusing? Please describe.
I find it very counterintuitive that the encoding of the hyperparameters depends on the presence of source_dir
behind the scenes. I wasted a lot of time debugging this issue after I moved to a setup with no source_dir
. Ideally, this should not happen and, in any case, this should not be a detail that's hidden deep inside.
See:
sagemaker-python-sdk/src/sagemaker/estimator.py
Lines 3283 to 3298 in 2f86ad9
def set_hyperparameters(self, **kwargs): | |
"""Sets the hyperparameter dictionary to use for training. | |
The hyperparameters are made accessible as a dict[str, str] to the | |
training code on SageMaker. For convenience, this accepts other types | |
for keys and values, but ``str()`` will be called to convert them before | |
training. | |
If a source directory is specified, this method escapes the dict argument as JSON, | |
and updates the private hyperparameter attribute. | |
""" | |
if self.source_dir: | |
self._hyperparameters.update(EstimatorBase._json_encode_hyperparameters(kwargs)) | |
else: | |
for k, v in kwargs.items(): | |
self._hyperparameters[k] = v |
Describe how documentation can be improved
This behavior should ideally NOT exist. However, if there are strong reasons for this, at least it should be mentioned in the docstring for source_dir
and/or hyperparameters
.
Additional context

Metadata
Metadata
Assignees
Labels
component: pysdk-teamRelated to SageMaker Python SDK Core IssuesRelated to SageMaker Python SDK Core Issuescomponent: trainingRelates to the SageMaker Training PlatformRelates to the SageMaker Training Platformtype: documentation
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Encoding of hyperparamters depends of the `source_dir`[/-][+]Encoding of hyperparamters depends on the `source_dir`[/+]mollyheamazon commentedon Jun 3, 2025
Updated in PR: #5190