Skip to content

Encoding of hyperparamters depends on the source_dir #5126

@abdulfatir

Description

@abdulfatir

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:

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

Image

Activity

changed the title [-]Encoding of hyperparamters depends of the `source_dir`[/-] [+]Encoding of hyperparamters depends on the `source_dir`[/+] on Apr 14, 2025
self-assigned this
on Jun 2, 2025
mollyheamazon

mollyheamazon commented on Jun 3, 2025

@mollyheamazon
Contributor

Updated in PR: #5190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @abdulfatir@nargokul@mollyheamazon

      Issue actions

        Encoding of hyperparamters depends on the `source_dir` · Issue #5126 · aws/sagemaker-python-sdk