Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure.ai.ml.MLClient causes TypeError: Plain typing.Annotated is not valid as type argument #39314

Closed
rafaelpierre opened this issue Jan 20, 2025 · 5 comments
Assignees
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Machine Learning

Comments

@rafaelpierre
Copy link

  • Package Name: azure-ai-ml
  • Package Version: 1.24.0
  • Operating System: macOS
  • Python Version: 3.13.0

Describe the bug
Importing azure.ai.ml.MLClient raises TypeError: Plain typing.Annotated is not valid as type argument

To Reproduce
Steps to reproduce the behavior:

  1. pip install azure-ai-ml
  2. Import azure.ai.ml.MLClient in any Python script.
  3. Run the script.

Expected behavior
Importing MLClient happens without any issues.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

uv pip freeze results in the following:

asgiref==3.8.1
attrs==24.3.0
azure-ai-ml==1.24.0
azure-common==1.1.28
azure-core==1.32.0
azure-core-tracing-opentelemetry==1.0.0b11
azure-identity==1.19.0
azure-mgmt-core==1.5.0
azure-monitor-opentelemetry==1.6.4
azure-monitor-opentelemetry-exporter==1.0.0b33
azure-storage-blob==12.24.0
azure-storage-file-datalake==12.18.0
azure-storage-file-share==12.20.0
certifi==2024.12.14
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
cryptography==44.0.0
deprecated==1.2.15
fixedint==0.1.6
idna==3.10
importlib-metadata==8.5.0
iniconfig==2.0.0
isodate==0.7.2
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
marshmallow==3.25.1
msal==1.31.1
msal-extensions==1.2.0
msrest==0.7.1
oauthlib==3.2.2
opentelemetry-api==1.29.0
opentelemetry-instrumentation==0.50b0
opentelemetry-instrumentation-asgi==0.50b0
opentelemetry-instrumentation-dbapi==0.50b0
opentelemetry-instrumentation-django==0.50b0
opentelemetry-instrumentation-fastapi==0.50b0
opentelemetry-instrumentation-flask==0.50b0
opentelemetry-instrumentation-psycopg2==0.50b0
opentelemetry-instrumentation-requests==0.50b0
opentelemetry-instrumentation-urllib==0.50b0
opentelemetry-instrumentation-urllib3==0.50b0
opentelemetry-instrumentation-wsgi==0.50b0
opentelemetry-resource-detector-azure==0.1.5
opentelemetry-sdk==1.29.0
opentelemetry-semantic-conventions==0.50b0
opentelemetry-util-http==0.50b0
packaging==24.2
pluggy==1.5.0
portalocker==2.10.1
psutil==5.9.8
pycparser==2.22
pydash==8.0.5
pyjwt==2.10.1
pytest==8.3.4
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
pyyaml==6.0.2
referencing==0.36.1
requests==2.32.3
requests-oauthlib==2.0.0
rpds-py==0.22.3
ruff==0.8.6
six==1.17.0
strictyaml==1.7.3
tqdm==4.67.1
typing-extensions==4.12.2
urllib3==2.3.0
wrapt==1.17.2
zipp==3.21.0

Full stderr / stdout:

(sdk) ➜  sdk git:(main) ✗ uv run pytest tests
========================================== test session starts ==========================================
platform darwin -- Python 3.13.0, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/rafaelpierre/projects/ai_foundry_sandbox/sdk
configfile: pyproject.toml
collected 1 item                                                                                        

tests/integration/test_marketplace_subscription.py F                                              [100%]

=============================================== FAILURES ================================================
__________________________________________ test_import_client ___________________________________________

    def test_import_client():
    
>       from azure.ai.ml import MLClient

tests/integration/test_marketplace_subscription.py:9: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.venv/lib/python3.13/site-packages/azure/ai/ml/__init__.py:11: in <module>
    from azure.ai.ml.entities._inputs_outputs import Input, Output
.venv/lib/python3.13/site-packages/azure/ai/ml/entities/__init__.py:18: in <module>
    from ._assets._artifacts._package.base_environment_source import BaseEnvironment
.venv/lib/python3.13/site-packages/azure/ai/ml/entities/_assets/__init__.py:9: in <module>
    from ._artifacts.code import Code
.venv/lib/python3.13/site-packages/azure/ai/ml/entities/_assets/_artifacts/code.py:16: in <module>
    from azure.ai.ml.entities._util import load_from_dict
.venv/lib/python3.13/site-packages/azure/ai/ml/entities/_util.py:20: in <module>
    from .._schema._deployment.batch.batch_deployment import BatchDeploymentSchema
.venv/lib/python3.13/site-packages/azure/ai/ml/_schema/_deployment/batch/batch_deployment.py:21: in <module>
    from azure.ai.ml._schema.pipeline.pipeline_component import PipelineComponentFileRefField
.venv/lib/python3.13/site-packages/azure/ai/ml/_schema/pipeline/__init__.py:7: in <module>
    from .component_job import (
.venv/lib/python3.13/site-packages/azure/ai/ml/_schema/pipeline/component_job.py:27: in <module>
    from ...entities._inputs_outputs import Input
.venv/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/__init__.py:57: in <module>
    from .enum_input import EnumInput
.venv/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/enum_input.py:10: in <module>
    from .input import Input
.venv/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/input.py:25: in <module>
    from .utils import _get_param_with_standard_annotation, _remove_empty_values
.venv/lib/python3.13/site-packages/azure/ai/ml/entities/_inputs_outputs/utils.py:28: in <module>
    Annotation: TypeAlias = Union[str, Type, Annotated, None]  # type: ignore
../../../.pyenv/versions/3.13.0/lib/python3.13/typing.py:432: in inner
    return func(*args, **kwds)
../../../.pyenv/versions/3.13.0/lib/python3.13/typing.py:576: in __getitem__
    return self._getitem(self, parameters)
../../../.pyenv/versions/3.13.0/lib/python3.13/typing.py:789: in Union
    parameters = tuple(_type_check(p, msg) for p in parameters)
../../../.pyenv/versions/3.13.0/lib/python3.13/typing.py:789: in <genexpr>
    parameters = tuple(_type_check(p, msg) for p in parameters)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

arg = typing.Annotated, msg = 'Union[arg, ...]: each arg must be a type.', is_argument = True
module = None

    def _type_check(arg, msg, is_argument=True, module=None, *, allow_special_forms=False):
        """Check that the argument is a type, and return it (internal helper).
    
        As a special case, accept None and return type(None) instead. Also wrap strings
        into ForwardRef instances. Consider several corner cases, for example plain
        special forms like Union are not valid, while Union[int, str] is OK, etc.
        The msg argument is a human-readable error message, e.g.::
    
            "Union[arg, ...]: arg should be a type."
    
        We append the repr() of the actual value (truncated to 100 chars).
        """
        invalid_generic_forms = (Generic, Protocol)
        if not allow_special_forms:
            invalid_generic_forms += (ClassVar,)
            if is_argument:
                invalid_generic_forms += (Final,)
    
        arg = _type_convert(arg, module=module, allow_special_forms=allow_special_forms)
        if (isinstance(arg, _GenericAlias) and
                arg.__origin__ in invalid_generic_forms):
            raise TypeError(f"{arg} is not valid as type argument")
        if arg in (Any, LiteralString, NoReturn, Never, Self, TypeAlias):
            return arg
        if allow_special_forms and arg in (ClassVar, Final):
            return arg
        if isinstance(arg, _SpecialForm) or arg in (Generic, Protocol):
>           raise TypeError(f"Plain {arg} is not valid as type argument")
E           TypeError: Plain typing.Annotated is not valid as type argument

../../../.pyenv/versions/3.13.0/lib/python3.13/typing.py:200: TypeError
=========================================== warnings summary ============================================
tests/integration/test_marketplace_subscription.py::test_import_client
  /Users/rafaelpierre/projects/ai_foundry_sandbox/sdk/.venv/lib/python3.13/site-packages/azure/ai/ml/_restclient/v2023_10_01/models/_azure_machine_learning_services_enums.py:208: SyntaxWarning: invalid escape sequence '\ '
    """Random forest is a supervised learning algorithm.

tests/integration/test_marketplace_subscription.py::test_import_client
  /Users/rafaelpierre/projects/ai_foundry_sandbox/sdk/.venv/lib/python3.13/site-packages/azure/ai/ml/_restclient/v2023_10_01/models/_azure_machine_learning_services_enums.py:1327: SyntaxWarning: invalid escape sequence '\ '
    """Random forest is a supervised learning algorithm.

tests/integration/test_marketplace_subscription.py::test_import_client
  /Users/rafaelpierre/projects/ai_foundry_sandbox/sdk/.venv/lib/python3.13/site-packages/azure/ai/ml/_schema/component/input_output.py:124: ChangedInMarshmallow4Warning: `Number` field should not be instantiated. Use `Integer`, `Float`, or `Decimal` instead.
    default = UnionField([fields.Str(), fields.Number(), fields.Bool()])

tests/integration/test_marketplace_subscription.py::test_import_client
  /Users/rafaelpierre/projects/ai_foundry_sandbox/sdk/.venv/lib/python3.13/site-packages/azure/ai/ml/_schema/component/input_output.py:126: ChangedInMarshmallow4Warning: `Number` field should not be instantiated. Use `Integer`, `Float`, or `Decimal` instead.
    max = UnionField([fields.Str(), fields.Number()])

tests/integration/test_marketplace_subscription.py::test_import_client
  /Users/rafaelpierre/projects/ai_foundry_sandbox/sdk/.venv/lib/python3.13/site-packages/azure/ai/ml/_schema/component/input_output.py:127: ChangedInMarshmallow4Warning: `Number` field should not be instantiated. Use `Integer`, `Float`, or `Decimal` instead.
    min = UnionField([fields.Str(), fields.Number()])

tests/integration/test_marketplace_subscription.py::test_import_client
  /Users/rafaelpierre/projects/ai_foundry_sandbox/sdk/.venv/lib/python3.13/site-packages/azure/ai/ml/_schema/_sweep/sweep_sampling_algorithm.py:30: ChangedInMarshmallow4Warning: `Number` field should not be instantiated. Use `Integer`, `Float`, or `Decimal` instead.
    fields.Number(),

tests/integration/test_marketplace_subscription.py::test_import_client
  /Users/rafaelpierre/projects/ai_foundry_sandbox/sdk/.venv/lib/python3.13/site-packages/azure/ai/ml/_schema/assets/index.py:17: RemovedInMarshmallow4Warning: The 'default' argument to fields is deprecated. Use 'dump_default' instead.
    stage = fields.Str(default="Development")
@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Jan 20, 2025
@jonaslb
Copy link

jonaslb commented Jan 20, 2025

#37600

@kristapratico kristapratico added bug This issue requires a change to an existing behavior in the product in order to be resolved. Machine Learning Service Attention Workflow: This issue is responsible by Azure service team. Client This issue points to a problem in the data-plane of the library. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Jan 21, 2025
@github-actions github-actions bot added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Jan 21, 2025
Copy link

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/azure-ml-sdk @azureml-github.

@jayesh-tanna
Copy link
Member

we started supporting py3.13 version. Please check this.
#37600

@jayesh-tanna jayesh-tanna added issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. and removed Service Attention Workflow: This issue is responsible by Azure service team. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team labels Feb 19, 2025
Copy link

Hi @rafaelpierre. 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.

Copy link

Hi @rafaelpierre, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Machine Learning
Projects
None yet
Development

No branches or pull requests

4 participants