aws/sagemaker-training-toolkit

No support for Python 3.10

peter-wimsey opened this issue · 9 comments

The library cannot be used in Python 3.10

Here's the error when trying to run train in a SageMaker training image:

Traceback (most recent call last):
  File "/opt/venv/bin/train", line 5, in <module>
    from sagemaker_training.cli.train import main
  File "/opt/venv/lib/python3.10/site-packages/sagemaker_training/cli/train.py", line 14, in <module>
    from sagemaker_training import trainer
  File "/opt/venv/lib/python3.10/site-packages/sagemaker_training/trainer.py", line 23, in <module>
    from sagemaker_training import (
  File "/opt/venv/lib/python3.10/site-packages/sagemaker_training/entry_point.py", line 24, in <module>
    from sagemaker_training import _entry_point_type, environment, files, modules, runner
  File "/opt/venv/lib/python3.10/site-packages/sagemaker_training/environment.py", line 32, in <module>
    from sagemaker_training import logging_config, mapping, params
  File "/opt/venv/lib/python3.10/site-packages/sagemaker_training/mapping.py", line 155, in <module>
    class MappingMixin(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'

The offending import gave a warning in Python 3.9

Python 3.9.12 (main, Apr  5 2022, 06:56:58) 
>>> import collections
>>> collections.Mapping
<stdin>:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
<class 'collections.abc.Mapping'>

but is an error in Python 3.10

Python 3.10.4 (main, Apr  2 2022, 09:04:19)
>>> import collections
>>> collections.Mapping
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'collections' has no attribute 'Mapping'

https://github.com/aws/sagemaker-training-toolkit/blob/v4.1.2/src/sagemaker_training/mapping.py#L155

Hi @peter-wimsey , we usually keep this package in sync with https://github.com/aws/deep-learning-containers/blob/master/available_images.md
When the py3.10 Deep Learning Container images are planned to release, we will update this package to make it compatible with python 3.10. I will keep this issue open to track it.

Will this get resolved? It's blocking us from using sagemaker-training-toolkit as we use python 3.10

@dsradecki maybe try #148? This works for me with Python 3.10.

Fixed with #156 I think.

Has there been movement on this? I am blocked on this and may be the deciding factor for me to drop sagemaker altogether.

Hi @satishpasumarthi, we are currently upgrading our Python proejct runtime from 3.8 to 3.10, as Python 3.8 is approaching the end of its life. However, we discovered that the current latest version sagemaker-training package is not compatible with Python 3.10. This incompatibility is blocking us from using the sagemaker-training-toolkit with the newer Python version.

Are there any plans to upgrade the sagemaker-training package to be compatible with Python 3.10?

I use the package with Python 3.11 and it works. Not sure if poetry does not check these version restrictions in the metadata but the code runs after #156 was merged and released.

Now it seems fixed officially: #214, which is part of the most recent release.

Now it seems fixed officially: #214, which is part of the most recent release.

Thanks, the 3.10 version support can be seen on sagemaker-training.