Skip to content

Commit 2429dfc

Browse files
authored
[ML]: fix: Index Operation Fixes (#35434)
* fix: Re-add missing @properties decorator * style: Run isort on ml_client.py * feat: Set default Index.stage to Development * fix: Format Index.path as a datastore uri instead of a storage uri This in support of the work done for build_index
1 parent 7f3fcc1 commit 2429dfc

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

sdk/ml/azure-ai-ml/azure/ai/ml/_ml_client.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@
4444
from azure.ai.ml._scope_dependent_operations import OperationConfig, OperationsContainer, OperationScope
4545
from azure.ai.ml._telemetry.logging_handler import get_appinsights_log_handler
4646
from azure.ai.ml._user_agent import USER_AGENT
47+
from azure.ai.ml._utils._experimental import experimental
4748
from azure.ai.ml._utils._http_utils import HttpPipeline
4849
from azure.ai.ml._utils._preflight_utils import get_deployments_operation
4950
from azure.ai.ml._utils._registry_utils import get_registry_client
5051
from azure.ai.ml._utils.utils import _is_https_url
51-
from azure.ai.ml._utils._experimental import experimental
5252
from azure.ai.ml.constants._common import AzureMLResourceType, DefaultOpenEncoding
5353
from azure.ai.ml.entities import (
5454
BatchDeployment,
@@ -59,16 +59,16 @@
5959
Environment,
6060
Index,
6161
Job,
62+
MarketplaceSubscription,
6263
Model,
6364
ModelBatchDeployment,
6465
OnlineDeployment,
6566
OnlineEndpoint,
6667
PipelineComponentBatchDeployment,
6768
Registry,
6869
Schedule,
69-
Workspace,
7070
ServerlessEndpoint,
71-
MarketplaceSubscription,
71+
Workspace,
7272
)
7373
from azure.ai.ml.entities._assets import WorkspaceAssetReference
7474
from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, ValidationException
@@ -77,19 +77,19 @@
7777
BatchEndpointOperations,
7878
ComponentOperations,
7979
ComputeOperations,
80+
ConnectionsOperations,
8081
DataOperations,
8182
DatastoreOperations,
8283
EnvironmentOperations,
8384
IndexOperations,
8485
JobOperations,
86+
MarketplaceSubscriptionOperations,
8587
ModelOperations,
8688
OnlineDeploymentOperations,
8789
OnlineEndpointOperations,
8890
RegistryOperations,
89-
ConnectionsOperations,
90-
WorkspaceOperations,
9191
ServerlessEndpointOperations,
92-
MarketplaceSubscriptionOperations,
92+
WorkspaceOperations,
9393
)
9494
from azure.ai.ml.operations._code_operations import CodeOperations
9595
from azure.ai.ml.operations._feature_set_operations import FeatureSetOperations
@@ -1033,6 +1033,7 @@ def marketplace_subscriptions(self) -> MarketplaceSubscriptionOperations:
10331033
"""
10341034
return self._marketplace_subscriptions
10351035

1036+
@property
10361037
def indexes(self) -> IndexOperations:
10371038
"""A collection of index related operations.
10381039

sdk/ml/azure-ai-ml/azure/ai/ml/entities/_assets/_artifacts/index.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
# cspell:disable-next-line
88
from azure.ai.ml._restclient.azure_ai_assets_v2024_04_01.azureaiassetsv20240401.models import Index as RestIndex
9-
from azure.ai.ml._utils._arm_id_utils import AMLAssetId
9+
from azure.ai.ml._utils._arm_id_utils import AMLAssetId, AMLNamedArmId
1010
from azure.ai.ml._utils._experimental import experimental
11+
from azure.ai.ml.constants._common import LONG_URI_FORMAT
1112
from azure.ai.ml.entities._assets import Artifact
1213
from azure.ai.ml.entities._assets._artifacts.artifact import ArtifactStorageInfo
1314
from azure.ai.ml.entities._system_data import RestSystemData, SystemData
@@ -42,7 +43,7 @@ def __init__(
4243
*,
4344
name: str,
4445
version: str,
45-
stage: str,
46+
stage: str = "Development",
4647
description: Optional[str] = None,
4748
tags: Optional[Dict[str, str]] = None,
4849
properties: Optional[Dict[str, str]] = None,
@@ -117,4 +118,11 @@ def _update_path(self, asset_artifact: ArtifactStorageInfo) -> None:
117118
118119
:param ArtifactStorageInfo asset_artifact: The asset storage info of the artifact
119120
"""
120-
self.path = asset_artifact.full_storage_path
121+
aml_datastore_id = AMLNamedArmId(asset_artifact.datastore_arm_id)
122+
self.path = LONG_URI_FORMAT.format(
123+
aml_datastore_id.subscription_id,
124+
aml_datastore_id.resource_group_name,
125+
aml_datastore_id.workspace_name,
126+
aml_datastore_id.asset_name,
127+
asset_artifact.relative_path,
128+
)

0 commit comments

Comments
 (0)