Skip to content

Commit

Permalink
fix: Resolve azd crash when using the ai.endpoint service host wi…
Browse files Browse the repository at this point in the history
…th Python 3.8 (#4092)

* fix: Use typing.List instead of subscripting list

     Support for using builtin types as generics
     (i.e. `list[int]` or `dict[str, str]`) was only added in Python 3.9.

     Before this commit, running `ml_client.py` on Python3.8 would
     crash azd.

     See PEP 385: https://peps.python.org/pep-0585/

* style: Run isort on ml_client.py
  • Loading branch information
kdestin authored Jul 10, 2024
1 parent 1f974c9 commit 837d4e8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cli/azd/resources/ai-python/ml_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
# coding: utf-8

import argparse
from typing import List

from azure.ai.ml import MLClient, load_environment, load_model, load_online_deployment, load_online_endpoint
from azure.identity import AzureDeveloperCliCredential
from azure.ai.ml import MLClient, load_environment, load_model, load_online_endpoint, load_online_deployment

def create_or_update_environment(client: MLClient, file_path: str, overrides: list[dict]):

def create_or_update_environment(client: MLClient, file_path: str, overrides: List[dict]):
environment = load_environment(source=file_path, params_override=overrides)
client.environments.create_or_update(environment)

def create_or_update_model(client: MLClient, file_path: str, overrides: list[dict]):
def create_or_update_model(client: MLClient, file_path: str, overrides: List[dict]):
model = load_model(source=file_path, params_override=overrides)
client.models.create_or_update(model)

def create_or_update_online_endpoint(client: MLClient, file_path: str, overrides: list[dict]):
def create_or_update_online_endpoint(client: MLClient, file_path: str, overrides: List[dict]):
online_endpoint = load_online_endpoint(source=file_path, params_override=overrides)
client.online_endpoints.begin_create_or_update(online_endpoint)

def create_or_update_online_deployment(client: MLClient, file_path: str, overrides: list[dict]):
def create_or_update_online_deployment(client: MLClient, file_path: str, overrides: List[dict]):
deployment = load_online_deployment(source=file_path, params_override=overrides)
client.online_deployments.begin_create_or_update(deployment)

Expand Down

0 comments on commit 837d4e8

Please sign in to comment.