typing.Annotated used in invalid context and raises error on python 3.13
Python 3.13 will be released in early October. We tested libraries against the final 3.13 release candidate in this PR: https://github.com/Azure/azure-sdk-for-python/pull/37508
With running 3.13, azure-ai-ml raises an error due to how typing.Annotated is used in the utils.py file:
File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/_schema/pipeline/component_job.py", line 27, in <module>
from ...entities._inputs_outputs import Input
File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/__init__.py", line 57, in <module>
from .enum_input import EnumInput
File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/enum_input.py", line 10, in <module>
from .input import Input
File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/input.py", line 25, in <module>
from .utils import _get_param_with_standard_annotation, _remove_empty_values
File "/mnt/vss/_work/1/s/sdk/ml/azure-ai-ml/.tox/depends/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/utils.py", line 28, in <module>
Annotation: TypeAlias = Union[str, Type, Annotated, None] # type: ignore
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 432, in inner
return func(*args, **kwds)
File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 576, in __getitem__
return self._getitem(self, parameters)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 789, in Union
parameters = tuple(_type_check(p, msg) for p in parameters)
File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 789, in <genexpr>
parameters = tuple(_type_check(p, msg) for p in parameters)
~~~~~~~~~~~^^^^^^^^
File "/opt/hostedtoolcache/Python/3.13.0-rc.2/x64/lib/python3.13/typing.py", line 200, in _type_check
raise TypeError(f"Plain {arg} is not valid as type argument")
TypeError: Plain typing.Annotated is not valid as type argument
Link to build: https://dev.azure.com/azure-sdk/public/_build/results?buildId=4167512&view=logs&j=447d33cb-e696-5bdf-6dab-daffaacae469&t=2668954e-6e9c-59cf-d60a-a6cb495508c0&l=1743
It would be good to fix this promptly in case there are other issues with 3.13.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github.
Thanks for the feedback. We will work on this and get back to you as soon as possible.
we are yet to support python 3.13. Its in our backlog. Once we start supporting this version this issue will be resolved. Thank you!
@pdhotems happy to sync offline as we're all FTE with @kristapratico . Azure SDK guidelines are quite clear that any SDK supports new version of Python immediately at their release, and strong effort needs to be made to be sure customers are not prevented to use the Python version they want. This issue needs to stay open, and I'd like a plan from you to solve that issue asap.
CC @rohit-ganguly
azure-ai-ml library have hard dependency on azureml-dataprep-rslex and this package is not yet compatible with Python 3.13. Once this package will be upgraded to 3.13, we can start supporting py 3.13 for azure-ai-ml and ETA for upgradation is end of Jan 2025.
we just hit this issue today with python 3.13 which is now default in conda create - would be great if it could be fixed
update, been hitting this issue for a while now.
azure-ai-ml library have hard dependency on azureml-dataprep-rslex and this package is not yet compatible with Python 3.13. Once this package will be upgraded to 3.13, we can start supporting py 3.13 for azure-ai-ml and ETA for upgradation is end of Jan 2025.
@jayesh-tanna maybe I'm missing something but azureml-dataprep-rslex looks like an optional dependency:
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ml/azure-ai-ml/setup.py#L100
I'm not sure how this package relates to the typing error in the original issue. Could we look into fixing the TypeError to unblock customers on 3.13?
azure-ai-ml library have hard dependency on azureml-dataprep-rslex and this package is not yet compatible with Python 3.13. Once this package will be upgraded to 3.13, we can start supporting py 3.13 for azure-ai-ml and ETA for upgradation is end of Jan 2025.
@jayesh-tanna maybe I'm missing something but
azureml-dataprep-rslexlooks like an optional dependency: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ml/azure-ai-ml/setup.py#L100I'm not sure how this package relates to the typing error in the original issue. Could we look into fixing the TypeError to unblock customers on 3.13?
@kristapratico can you go through https://github.com/Azure/azure-sdk-for-python/pull/39290, it should fix the issue at hand, particular for azure-ai-ml package
azure-ai-ml library have hard dependency on azureml-dataprep-rslex and this package is not yet compatible with Python 3.13. Once this package will be upgraded to 3.13, we can start supporting py 3.13 for azure-ai-ml and ETA for upgradation is end of Jan 2025.
@jayesh-tanna maybe I'm missing something but
azureml-dataprep-rslexlooks like an optional dependency: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/ml/azure-ai-ml/setup.py#L100 I'm not sure how this package relates to the typing error in the original issue. Could we look into fixing the TypeError to unblock customers on 3.13?@kristapratico can you go through #39290, it should fix the issue at hand, particular for azure-ai-ml package
@eff-kay I'm not the owner of this library so I don't have a good understanding of the code in this module. I'll tag @azureml-github to take a look at the PR, but at a quick glance I don't think importing a private type from typing_extensions is a reliable fix.
+1 on this issue -- also experiencing this problem
I believe I'm having the same issue with Azure CLI and Python 3.13 (Fedora 41):
$ az ml -h
--- snip ---
cli.azure.cli.core: Unable to load extension 'ml: Plain typing.Annotated is not valid as type argument'. Use --debug for more information.
cli.azure.cli.core: Traceback (most recent call last):
--- snip ---
File "/home/myuser/.azure/cliextensions/ml/azext_mlv2/manual/vendored_curated_sdk/azure/ai/ml/entities/_inputs_outputs/utils.py", line 28, in <module>
Annotation: TypeAlias = Union[str, Type, Annotated, None] # type: ignore
~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.13/typing.py", line 432, in inner
return func(*args, **kwds)
File "/usr/lib64/python3.13/typing.py", line 576, in __getitem__
return self._getitem(self, parameters)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/usr/lib64/python3.13/typing.py", line 789, in Union
parameters = tuple(_type_check(p, msg) for p in parameters)
File "/usr/lib64/python3.13/typing.py", line 789, in <genexpr>
parameters = tuple(_type_check(p, msg) for p in parameters)
~~~~~~~~~~~^^^^^^^^
File "/usr/lib64/python3.13/typing.py", line 200, in _type_check
raise TypeError(f"Plain {arg} is not valid as type argument")
TypeError: Plain typing.Annotated is not valid as type argument
--- snip ---
cli.azure.cli.core.command_recommender: "--name" is an invalid parameter for command "ml".
cli.azure.cli.core.azclierror: NoneType: None
cli.azure.cli.core.azclierror: 'ml' is misspelled or not recognized by the system.
az_command_data_logger: 'ml' is misspelled or not recognized by the system.
dependency on azureml-dataprep-rslex is that its added as mandatory package in dev_requirements.txt hence, needs to make it optional and needs to solve annotation error as well.
dependency on azureml-dataprep-rslex is that its added as mandatory package in dev_requirements.txt hence, needs to make it optional and needs to solve annotation error as well.
@jayesh-tanna does #39482 fixes this issue?
Yes azure-ai-ml starts supporting py3.13. However if you are using mount (azureml-dataprep-rslex), you have to use py3.12 or below version only.
Hi @kristapratico. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.
Hi @kristapratico, since you haven’t asked that we /unresolve the issue, we’ll close this out. If you believe further discussion is needed, please add a comment /unresolve to reopen the issue.