gluonts.shell.sagemaker.params module

gluonts.shell.sagemaker.params.decode_sagemaker_parameter(value: str) → Union[list, dict, str][source]

All values passed through the SageMaker API are encoded as strings. Thus we pro-actively decode values that seem like arrays or dicts.

Integer values (e.g. “1”) are handled by pydantic models further down the pipeline.

gluonts.shell.sagemaker.params.decode_sagemaker_parameters(encoded_params: dict) → dict[source]

Decode a SageMaker parameters dictionary where all values are strings.

Example:

>>> decode_sagemaker_parameters({
...     "foo": "[1, 2, 3]",
...     "bar": "hello"
... })
{'foo': [1, 2, 3], 'bar': 'hello'}
gluonts.shell.sagemaker.params.detrim_and_decode_sagemaker_parameters(trimmed_params: dict) → dict[source]

Decode a SageMaker parameters dictionary where all values are strings.

Example:

>>> detrim_and_decode_sagemaker_parameters({
...     '_0_foo': '[1, ',
...     '_1_foo': '2, 3',
...     '_2_foo': ']',
...     '_0_bar': 'hell',
...     '_1_bar': 'o'
... })
{'foo': [1, 2, 3], 'bar': 'hello'}
gluonts.shell.sagemaker.params.detrim_sagemaker_parameters(trimmed_params: dict) → dict[source]

DE-trim parameters that have already been trimmed.

Example:

>>> detrim_sagemaker_parameters({
...     '_0_foo': '[1, ',
...     '_1_foo': '2, 3',
...     '_2_foo': ']',
...     '_0_bar': 'hell',
...     '_1_bar': 'o'
... })
{'foo': '[1, 2, 3]', 'bar': 'hello'}
gluonts.shell.sagemaker.params.encode_and_trim_sagemaker_parameters(decoded_params: dict, max_len: int = 256) → dict[source]

Encode a SageMaker parameters dictionary where all values are strings then trim them to account for Sagemaker character size limit.

>>> encode_and_trim_sagemaker_parameters({
...     "foo": [1, 2, 3],
...     "bar": "hello"
... }, max_len = 4)
{'_0_foo': '[1, ',
 '_1_foo': '2, 3',
 '_2_foo': ']',
 '_0_bar': 'hell',
 '_1_bar': 'o'}
gluonts.shell.sagemaker.params.encode_sagemaker_parameter(value: Any) → str[source]

All values passed through the SageMaker API must be encoded as strings.

gluonts.shell.sagemaker.params.encode_sagemaker_parameters(decoded_params: dict) → dict[source]

Encode a SageMaker parameters dictionary where all values are strings.

Example:

>>> encode_sagemaker_parameters({
...     "foo": [1, 2, 3],
...     "bar": "hello"
... })
{'foo': '[1, 2, 3]', 'bar': 'hello'}
gluonts.shell.sagemaker.params.trim_encoded_sagemaker_parameters(encoded_params: dict, max_len: int = 256) → dict[source]

Trim parameters that have already been encoded to a given max length.

Example:

>>> trim_encoded_sagemaker_parameters({
...     'foo': '[1, 2, 3]',
...     'bar': 'hello'
... }, max_len = 4)
{'_0_foo': '[1, ',
 '_1_foo': '2, 3',
 '_2_foo': ']',
 '_0_bar': 'hell',
 '_1_bar': 'o'}