azureml-registry-tools 0.1.0a3__tar.gz → 0.1.0a4__tar.gz

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.
Files changed (27) hide show
  1. {azureml_registry_tools-0.1.0a3/azureml_registry_tools.egg-info → azureml_registry_tools-0.1.0a4}/PKG-INFO +1 -1
  2. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/tools/create_or_update_assets.py +33 -15
  3. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4/azureml_registry_tools.egg-info}/PKG-INFO +1 -1
  4. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/setup.py +1 -1
  5. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/LICENSE.txt +0 -0
  6. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/__init__.py +0 -0
  7. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/__init__.py +0 -0
  8. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/_cli/__init__.py +0 -0
  9. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/_cli/registry_syndication_cli.py +0 -0
  10. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/_cli/repo2registry_cli.py +0 -0
  11. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/_rest_client/__init__.py +0 -0
  12. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/_rest_client/arm_client.py +0 -0
  13. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/_rest_client/base_rest_client.py +0 -0
  14. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/_rest_client/registry_management_client.py +0 -0
  15. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/mgmt/__init__.py +0 -0
  16. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/mgmt/create_manifest.py +0 -0
  17. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/mgmt/syndication_manifest.py +0 -0
  18. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/tools/__init__.py +0 -0
  19. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/tools/config.py +0 -0
  20. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/tools/registry_utils.py +0 -0
  21. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml/registry/tools/repo2registry_config.py +0 -0
  22. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml_registry_tools.egg-info/SOURCES.txt +0 -0
  23. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml_registry_tools.egg-info/dependency_links.txt +0 -0
  24. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml_registry_tools.egg-info/entry_points.txt +0 -0
  25. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml_registry_tools.egg-info/requires.txt +0 -0
  26. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/azureml_registry_tools.egg-info/top_level.txt +0 -0
  27. {azureml_registry_tools-0.1.0a3 → azureml_registry_tools-0.1.0a4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azureml-registry-tools
3
- Version: 0.1.0a3
3
+ Version: 0.1.0a4
4
4
  Summary: AzureML Registry tools and CLI
5
5
  Author: Microsoft Corp
6
6
  License: https://aka.ms/azureml-sdk-license
@@ -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
- updated_asset_file_name: str) -> dict:
125
- """Overwrite values from updated asset to existing asset with the exception of storage path.
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
- updated_asset_file_name (str): Name of file containing updated asset.
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(updated_asset_file_name, "r") as updated_asset_file:
135
- existing_asset_yaml = yaml.safe_load(existing_asset_file)
136
- updated_asset_yaml = yaml.safe_load(updated_asset_file)
137
- merged_asset = {**existing_asset_yaml, **updated_asset_yaml}
138
- merged_asset["path"] = existing_asset_yaml["path"]
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
- """Overwrite values from updated to existing asset while preserving existing asset path.
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
- merged_result = merge_yamls(existing_asset_temp_file_name, asset.file_name_with_path)
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 == AssetType.MODEL or asset.type == AssetType.DATA:
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:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: azureml-registry-tools
3
- Version: 0.1.0a3
3
+ Version: 0.1.0a4
4
4
  Summary: AzureML Registry tools and CLI
5
5
  Author: Microsoft Corp
6
6
  License: https://aka.ms/azureml-sdk-license
@@ -18,7 +18,7 @@ exclude_list = ["*.tests"]
18
18
 
19
19
  setup(
20
20
  name='azureml-registry-tools',
21
- version="0.1.0a3",
21
+ version="0.1.0a4",
22
22
  description='AzureML Registry tools and CLI',
23
23
  author='Microsoft Corp',
24
24
  license="https://aka.ms/azureml-sdk-license",