Skip to content

Commit aa62911

Browse files
using latest version for auto rest (Azure#40787)
* using latest version for autorest * fetching the component with correct name --------- Co-authored-by: Copilot <[email protected]>
1 parent b484b70 commit aa62911

File tree

3 files changed

+53
-53
lines changed

3 files changed

+53
-53
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/operations/_component_operations.py

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,42 @@
22
# Copyright (c) Microsoft Corporation. All rights reserved.
33
# ---------------------------------------------------------
44

5+
import collections
6+
import hashlib
7+
58
# pylint: disable=protected-access,too-many-lines
69
import time
7-
import collections
810
import types
911
from functools import partial
1012
from inspect import Parameter, signature
1113
from os import PathLike
1214
from pathlib import Path
1315
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union, cast
14-
import hashlib
1516

1617
from azure.ai.ml._restclient.v2021_10_01_dataplanepreview import (
1718
AzureMachineLearningWorkspaces as ServiceClient102021Dataplane,
1819
)
19-
from azure.ai.ml._restclient.v2024_01_01_preview import (
20-
AzureMachineLearningWorkspaces as ServiceClient012024,
21-
)
22-
from azure.ai.ml._restclient.v2024_01_01_preview.models import (
23-
ComponentVersion,
24-
ListViewType,
25-
)
20+
from azure.ai.ml._restclient.v2024_01_01_preview import AzureMachineLearningWorkspaces as ServiceClient012024
21+
from azure.ai.ml._restclient.v2024_01_01_preview.models import ComponentVersion, ListViewType
2622
from azure.ai.ml._scope_dependent_operations import (
2723
OperationConfig,
2824
OperationsContainer,
2925
OperationScope,
3026
_ScopeDependentOperations,
3127
)
32-
from azure.ai.ml._telemetry import (
33-
ActivityType,
34-
monitor_with_activity,
35-
monitor_with_telemetry_mixin,
36-
)
28+
from azure.ai.ml._telemetry import ActivityType, monitor_with_activity, monitor_with_telemetry_mixin
3729
from azure.ai.ml._utils._asset_utils import (
30+
IgnoreFile,
3831
_archive_or_restore,
3932
_create_or_update_autoincrement,
4033
_get_file_hash,
4134
_get_latest,
4235
_get_next_version_from_container,
4336
_resolve_label_to_asset,
37+
create_catalog_files,
38+
delete_two_catalog_files,
4439
get_ignore_file,
4540
get_upload_files_from_folder,
46-
IgnoreFile,
47-
delete_two_catalog_files,
48-
create_catalog_files,
4941
)
5042
from azure.ai.ml._utils._azureml_polling import AzureMLPolling
5143
from azure.ai.ml._utils._endpoint_utils import polling_wait
@@ -59,12 +51,7 @@
5951
LROConfigurations,
6052
)
6153
from azure.ai.ml.entities import Component, ValidationResult
62-
from azure.ai.ml.exceptions import (
63-
ComponentException,
64-
ErrorCategory,
65-
ErrorTarget,
66-
ValidationException,
67-
)
54+
from azure.ai.ml.exceptions import ComponentException, ErrorCategory, ErrorTarget, ValidationException
6855
from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
6956

7057
from .._utils._cache_utils import CachedNodeResolver
@@ -675,7 +662,7 @@ def create_or_update(
675662
)
676663

677664
if not result:
678-
component = self.get(name=component.name, version=component.version)
665+
component = self.get(name=name, version=version)
679666
else:
680667
component = Component._from_rest_object(result)
681668

@@ -915,9 +902,7 @@ def _resolve_binding_on_supported_fields_for_node(cls, node: BaseNode) -> None:
915902
:param node: The node
916903
:type node: BaseNode
917904
"""
918-
from azure.ai.ml.entities._job.pipeline._attr_dict import (
919-
try_get_non_arbitrary_attr,
920-
)
905+
from azure.ai.ml.entities._job.pipeline._attr_dict import try_get_non_arbitrary_attr
921906
from azure.ai.ml.entities._job.pipeline._io import PipelineInput
922907

923908
# compute binding to pipeline input is supported on node.

sdk/ml/azure-ai-ml/scripts/regenerate_restclient.py

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# coding: utf-8
2+
3+
# -------------------------------------------------------------------------
4+
# Copyright (c) Microsoft Corporation. All rights reserved.
5+
# Licensed under the MIT License. See License.txt in the project root for
6+
# license information.
7+
# --------------------------------------------------------------------------
8+
19
import logging
210
import os
311
import subprocess
@@ -44,27 +52,27 @@ def _run_command(
4452

4553
t0 = time.perf_counter()
4654
try:
47-
logger.debug("Executing {0} in {1}".format(commands, cwd))
55+
logger.debug("Executing %s in %s", commands, cwd)
4856
out = ""
49-
p = subprocess.Popen(commands, stdout=subprocess.PIPE, stderr=stderr, cwd=cwd, shell=shell, env=env)
50-
for line in p.stdout:
51-
line = line.decode("utf-8").rstrip()
52-
if line and line.strip():
53-
logger.debug(line)
54-
if stream_stdout:
55-
sys.stdout.write(line)
56-
sys.stdout.write("\n")
57-
out += line
58-
out += "\n"
59-
p.communicate()
60-
retcode = p.poll()
61-
if throw_on_retcode:
62-
if retcode:
63-
raise subprocess.CalledProcessError(retcode, p.args, output=out, stderr=p.stderr)
57+
with subprocess.Popen(commands, stdout=subprocess.PIPE, stderr=stderr, cwd=cwd, shell=shell, env=env) as p:
58+
for line in p.stdout:
59+
line = line.decode("utf-8").rstrip()
60+
if line and line.strip():
61+
logger.debug(line)
62+
if stream_stdout:
63+
sys.stdout.write(line)
64+
sys.stdout.write("\n")
65+
out += line
66+
out += "\n"
67+
p.communicate()
68+
retcode = p.poll()
69+
if throw_on_retcode:
70+
if retcode:
71+
raise subprocess.CalledProcessError(retcode, p.args, output=out, stderr=p.stderr)
6472
return retcode, out
6573
finally:
6674
t1 = time.perf_counter()
67-
logger.debug("Execution took {0}s for {1} in {2}".format(t1 - t0, commands, cwd))
75+
logger.debug("Execution took %ss for %s in %s", t1 - t0, commands, cwd)
6876

6977

7078
def run_command(
@@ -90,13 +98,13 @@ def download_file(from_url: str, to_path: Path, with_file_name: str) -> None:
9098
print_blue(f"- Downloading {with_file_name} from {from_url} to {to_path}")
9199

92100
try:
93-
response = urlopen(from_url)
94-
except Exception:
101+
with urlopen(from_url) as response:
102+
with open(f"{to_path}/{with_file_name}", "w", encoding="utf-8") as f:
103+
f.write(response.read().decode("utf-8"))
104+
except (OSError, URLError, HTTPError) as e:
95105
sys.exit(
96-
f"Connection error while trying to download file from {from_url}. Please try running the script again."
106+
f"Connection error while trying to download file from {from_url}: {e}. Please try running the script again."
97107
)
98-
with open(f"{to_path}/{with_file_name}", "w") as f:
99-
f.write(response.read().decode("utf-8"))
100108

101109

102110
def regenerate_restclient(api_tag, verbose):
@@ -115,7 +123,7 @@ def regenerate_restclient(api_tag, verbose):
115123
"--python",
116124
"--track2",
117125
"--version=3.6.2",
118-
"--use=@autorest/python@5.12.6",
126+
"--use=@autorest/python@latest",
119127
f"--python-sdks-folder={restclient_path.absolute()}",
120128
"--package-version=0.1.0",
121129
tag_arg,
@@ -138,8 +146,11 @@ def regenerate_restclient(api_tag, verbose):
138146
"-a",
139147
"--api-tag",
140148
required=False,
141-
help="""Specifies which API to generate using autorest. If not supplied, all APIs are targeted.
142-
Must match the name of a tag in the sdk/ml/azure-ai-ml/swagger/machinelearningservices/resource-manager/readme.md file.""",
149+
help=(
150+
"Specifies which API to generate using autorest. If not supplied, all APIs are targeted.\n"
151+
"Must match the name of a tag in the sdk/ml/azure-ai-ml/swagger/machinelearningservices/"
152+
"resource-manager/readme.md file."
153+
),
143154
)
144155
parser.add_argument("-v", "--verbose", action="store_true", required=False, help="turn on verbose output")
145156

sdk/ml/azure-ai-ml/swagger/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/preview/2025-01-01-preview/mfe.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4324,6 +4324,10 @@
43244324
"format": "int32",
43254325
"maximum": 600,
43264326
"minimum": 10
4327+
},
4328+
"Azure-AsyncOperation": {
4329+
"description": "URI to poll for asynchronous operation status.",
4330+
"type": "string"
43274331
}
43284332
}
43294333
},
@@ -4344,7 +4348,7 @@
43444348
},
43454349
"x-ms-long-running-operation": true,
43464350
"x-ms-long-running-operation-options": {
4347-
"final-state-via": "location"
4351+
"final-state-via": "azure-async-operation"
43484352
}
43494353
},
43504354
"get": {

0 commit comments

Comments
 (0)