azureml-registry-tools 0.1.0a3__py3-none-any.whl → 0.1.0a4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- azureml/registry/tools/create_or_update_assets.py +33 -15
- {azureml_registry_tools-0.1.0a3.dist-info → azureml_registry_tools-0.1.0a4.dist-info}/METADATA +1 -1
- {azureml_registry_tools-0.1.0a3.dist-info → azureml_registry_tools-0.1.0a4.dist-info}/RECORD +7 -7
- {azureml_registry_tools-0.1.0a3.dist-info → azureml_registry_tools-0.1.0a4.dist-info}/WHEEL +0 -0
- {azureml_registry_tools-0.1.0a3.dist-info → azureml_registry_tools-0.1.0a4.dist-info}/entry_points.txt +0 -0
- {azureml_registry_tools-0.1.0a3.dist-info → azureml_registry_tools-0.1.0a4.dist-info}/licenses/LICENSE.txt +0 -0
- {azureml_registry_tools-0.1.0a3.dist-info → azureml_registry_tools-0.1.0a4.dist-info}/top_level.txt +0 -0
@@ -5,6 +5,7 @@
|
|
5
5
|
"""Create or update assets."""
|
6
6
|
|
7
7
|
import azure
|
8
|
+
import copy
|
8
9
|
import json
|
9
10
|
import os
|
10
11
|
import re
|
@@ -14,7 +15,8 @@ from git import InvalidGitRepositoryError, Repo
|
|
14
15
|
from pathlib import Path
|
15
16
|
from typing import List, Union
|
16
17
|
|
17
|
-
from azure.ai.ml import MLClient, load_data, load_model
|
18
|
+
from azure.ai.ml import MLClient, load_component, load_data, load_model
|
19
|
+
from azure.ai.ml.entities._component.component import Component
|
18
20
|
from azure.ai.ml.entities._assets._artifacts.data import Data
|
19
21
|
from azure.ai.ml.entities._assets._artifacts.model import Model
|
20
22
|
from azure.identity import DefaultAzureCredential
|
@@ -121,38 +123,52 @@ def find_assets(input_dir: Path,
|
|
121
123
|
|
122
124
|
|
123
125
|
def merge_yamls(existing_asset_file_name: str,
|
124
|
-
|
125
|
-
"""
|
126
|
+
updated_asset: AssetSpec) -> dict:
|
127
|
+
"""Preserve storage value from existing asset to updated asset.
|
126
128
|
|
127
129
|
Args:
|
128
130
|
existing_asset_file_name (str): Name of file containing details of asset currently in registry.
|
129
|
-
|
130
|
-
|
131
|
+
updated_asset (AssetSpec): AssetSpec containing updated asset info.
|
131
132
|
Returns:
|
132
133
|
dict: Merged asset data.
|
133
134
|
"""
|
134
|
-
with open(existing_asset_file_name, "r") as existing_asset_file, open(
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
merged_asset
|
135
|
+
with open(existing_asset_file_name, "r") as existing_asset_file, open(updated_asset.file_name_with_path, "r") as updated_asset_file:
|
136
|
+
existing_asset_dict = yaml.safe_load(existing_asset_file)
|
137
|
+
updated_asset_dict = yaml.safe_load(updated_asset_file)
|
138
|
+
|
139
|
+
merged_asset = copy.deepcopy(updated_asset_dict)
|
140
|
+
|
141
|
+
if updated_asset.type == AssetType.MODEL or updated_asset.type == AssetType.DATA:
|
142
|
+
storage_key = "path"
|
143
|
+
# "path" is always required for models, use the existing value
|
144
|
+
if existing_asset_dict.get(storage_key) != updated_asset_dict.get(storage_key):
|
145
|
+
print(f'"{storage_key}" is immutable, using existing value from asset in registry: {existing_asset_dict[storage_key]}')
|
146
|
+
merged_asset[storage_key] = existing_asset_dict[storage_key]
|
147
|
+
elif updated_asset.type == AssetType.COMPONENT:
|
148
|
+
storage_key = "code"
|
149
|
+
if existing_asset_dict.get(storage_key) is None and updated_asset_dict.get(storage_key) is not None:
|
150
|
+
print(f'"{storage_key}" is immutable and cannot be added. Please create a new version to include "{storage_key}"')
|
151
|
+
elif existing_asset_dict.get(storage_key) != updated_asset_dict.get(storage_key):
|
152
|
+
print(f'"{storage_key}" is immutable, using existing value from asset in registry: {existing_asset_dict[storage_key]}')
|
153
|
+
merged_asset[storage_key] = existing_asset_dict[storage_key]
|
139
154
|
|
140
155
|
return merged_asset
|
141
156
|
|
142
157
|
|
143
|
-
def merge_assets(existing_asset: Union[Data, Model],
|
158
|
+
def merge_assets(existing_asset: Union[Component, Data, Model],
|
144
159
|
asset: AssetSpec):
|
145
|
-
"""
|
160
|
+
"""Prepare asset for update by preserving storage value from existing asset.
|
146
161
|
|
147
162
|
Args:
|
148
|
-
existing_asset (Union[Data, Model]): Asset currently in registry.
|
163
|
+
existing_asset (Union[Component, Data, Model]): Asset currently in registry.
|
149
164
|
asset (AssetSpec): AssetSpec containing updated asset info.
|
150
165
|
"""
|
151
166
|
with tempfile.NamedTemporaryFile(suffix=".yaml", delete=False) as existing_asset_temp_file:
|
152
167
|
existing_asset_temp_file_name = existing_asset_temp_file.name
|
153
168
|
|
154
169
|
existing_asset.dump(existing_asset_temp_file_name)
|
155
|
-
|
170
|
+
|
171
|
+
merged_result = merge_yamls(existing_asset_temp_file_name, asset)
|
156
172
|
|
157
173
|
with tempfile.NamedTemporaryFile(suffix=".yaml", delete=False) as merged_asset_temp_file:
|
158
174
|
merged_asset_temp_file_name = merged_asset_temp_file.name
|
@@ -164,6 +180,8 @@ def merge_assets(existing_asset: Union[Data, Model],
|
|
164
180
|
merged_asset = load_model(merged_asset_temp_file_name)
|
165
181
|
elif asset.type == AssetType.DATA:
|
166
182
|
merged_asset = load_data(merged_asset_temp_file_name)
|
183
|
+
elif asset.type == AssetType.COMPONENT:
|
184
|
+
merged_asset = load_component(merged_asset_temp_file_name)
|
167
185
|
|
168
186
|
asset.set_asset_obj_to_create_or_update(merged_asset)
|
169
187
|
|
@@ -289,7 +307,7 @@ def create_or_update_assets(input_dir: Path,
|
|
289
307
|
raise
|
290
308
|
|
291
309
|
if existing_asset:
|
292
|
-
if asset.type
|
310
|
+
if asset.type in [AssetType.COMPONENT, AssetType.DATA, AssetType.MODEL]:
|
293
311
|
try:
|
294
312
|
merge_assets(existing_asset, asset)
|
295
313
|
except Exception as e:
|
{azureml_registry_tools-0.1.0a3.dist-info → azureml_registry_tools-0.1.0a4.dist-info}/RECORD
RENAMED
@@ -12,12 +12,12 @@ azureml/registry/mgmt/create_manifest.py,sha256=N9wRmjAKO09A3utN_lCUsM_Ufpj7PL0S
|
|
12
12
|
azureml/registry/mgmt/syndication_manifest.py,sha256=ma1_vUEHHtkRcgiFMQanlXZajvKodynylxfblTHuleE,6195
|
13
13
|
azureml/registry/tools/__init__.py,sha256=IAuWWpGfZm__pAkBIxmpJz84QskpkxBr0yDk1TUSnkE,223
|
14
14
|
azureml/registry/tools/config.py,sha256=tjPaoBsWtPXBL8Ww1hcJtsr2SuIjPKt79dR8iovcebg,3639
|
15
|
-
azureml/registry/tools/create_or_update_assets.py,sha256=
|
15
|
+
azureml/registry/tools/create_or_update_assets.py,sha256=Q-_BV7KWn1huQn5JriKT_8xJNoQQ_HK5wCftrq9DepA,15988
|
16
16
|
azureml/registry/tools/registry_utils.py,sha256=zgYlCiOONtQJ4yZ9wg8tKVoE8dh6rrjB8hYBGhpV9-0,1403
|
17
17
|
azureml/registry/tools/repo2registry_config.py,sha256=eXp_tU8Jyi30g8xGf7wbpLgKEPpieohBANKxMSLzq7s,4873
|
18
|
-
azureml_registry_tools-0.1.
|
19
|
-
azureml_registry_tools-0.1.
|
20
|
-
azureml_registry_tools-0.1.
|
21
|
-
azureml_registry_tools-0.1.
|
22
|
-
azureml_registry_tools-0.1.
|
23
|
-
azureml_registry_tools-0.1.
|
18
|
+
azureml_registry_tools-0.1.0a4.dist-info/licenses/LICENSE.txt,sha256=n20rxwp7_NGrrShv9Qvcs90sjI1l3Pkt3m-5OPCWzgs,845
|
19
|
+
azureml_registry_tools-0.1.0a4.dist-info/METADATA,sha256=XCJDpX9oa2LTU8pUOVQOGjizcLtrlRYa1f0fECIa9tM,521
|
20
|
+
azureml_registry_tools-0.1.0a4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
azureml_registry_tools-0.1.0a4.dist-info/entry_points.txt,sha256=iRUkAeQidMnO6RQzpLqMUBTcyYtNzAfSin9WnSdVGLw,147
|
22
|
+
azureml_registry_tools-0.1.0a4.dist-info/top_level.txt,sha256=ZOeEa0TAXo6i5wOjwBoqfIGEuxOcKuscGgNSpizqREY,8
|
23
|
+
azureml_registry_tools-0.1.0a4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
{azureml_registry_tools-0.1.0a3.dist-info → azureml_registry_tools-0.1.0a4.dist-info}/top_level.txt
RENAMED
File without changes
|