azureml-registry-tools 0.1.0a6__py3-none-any.whl → 0.1.0a7__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.
@@ -4,10 +4,14 @@
4
4
  import argparse
5
5
  import json
6
6
  import sys
7
+ from pathlib import Path
7
8
  from uuid import UUID
8
9
  from azureml.registry._rest_client.registry_management_client import RegistryManagementClient
9
10
  from azureml.registry._rest_client.arm_client import ArmClient
11
+ from azureml.registry.mgmt.asset_management import asset_validate, asset_deploy
12
+ from azureml.registry.mgmt.create_asset_template import asset_template
10
13
  from azureml.registry.mgmt.create_manifest import generate_syndication_manifest
14
+ from azureml.registry.mgmt.registry_config import create_registry_config
11
15
  from azureml.registry.mgmt.syndication_manifest import SyndicationManifest, ResyncAssetsInManifestDto
12
16
 
13
17
 
@@ -133,6 +137,14 @@ def show_command(registry_name: str, as_arm_object: bool) -> object:
133
137
  return discovery
134
138
 
135
139
 
140
+ def validate_registry_cfg(cfg_file_name) -> str:
141
+ """Validate if registry config extension is .cfg."""
142
+ cfg_file_path = Path(cfg_file_name)
143
+ if not cfg_file_path.suffix == ".cfg":
144
+ raise argparse.ArgumentTypeError(f"--config arg {cfg_file_name} must be a path to a .cfg file")
145
+ return cfg_file_path
146
+
147
+
136
148
  def _add_common_args(p, arg_dicts=None):
137
149
  if arg_dicts is None:
138
150
  arg_dicts = []
@@ -168,6 +180,21 @@ def main() -> None:
168
180
  # Set target values
169
181
  registry-mgmt syndication target set --registry-name myreg -v reg1Id -v reg2Id
170
182
 
183
+ # Validate an asset
184
+ registry-mgmt asset validate --asset-path ./path-to-asset
185
+
186
+ # Deploy an asset to registry (using config file)
187
+ registry-mgmt asset deploy --asset-path ./path-to-asset --config ./registry-mgmt.cfg
188
+
189
+ # Create registry configuration file
190
+ registry-mgmt asset config --registry-name myreg --subscription sub123 --resource-group rg123 --tenant-id tenant123
191
+
192
+ # Create registry configuration file with storage overrides
193
+ registry-mgmt asset config --registry-name myreg --subscription sub123 --resource-group rg123 --tenant-id tenant123 --storage-name storage123 --container-name container123 --container-path path123
194
+
195
+ # Create asset template files
196
+ registry-mgmt asset template --folder ./folder-path
197
+
171
198
  # Show registry discovery info
172
199
  registry-mgmt show --registry-name myreg
173
200
 
@@ -235,6 +262,37 @@ def main() -> None:
235
262
  _add_common_args(target_set_parser, [registry_name_arg, dry_run_arg])
236
263
  target_set_parser.add_argument("-v", "--value", type=str, action="append", required=True, help="Target value (can be specified multiple times).")
237
264
 
265
+ # asset root command
266
+ asset_parser = subparsers.add_parser("asset", help="Asset management operations")
267
+ asset_subparsers = asset_parser.add_subparsers(dest="asset_subcommand", required=True)
268
+
269
+ # asset validate command
270
+ asset_validate_parser = asset_subparsers.add_parser("validate", help="Validate an asset.")
271
+ _add_common_args(asset_validate_parser, [dry_run_arg])
272
+ asset_validate_parser.add_argument("--asset-path", type=Path, help="Path to the asset folder to validate.")
273
+
274
+ # asset deploy command
275
+ asset_deploy_parser = asset_subparsers.add_parser("deploy", help="Deploy an asset to registry.")
276
+ _add_common_args(asset_deploy_parser, [dry_run_arg])
277
+ asset_deploy_parser.add_argument("-c", "--config", type=validate_registry_cfg, required=True, help="Path to registry config file.")
278
+ asset_deploy_parser.add_argument("--asset-path", type=Path, help="Path to the asset folder to deploy.")
279
+
280
+ # asset config command
281
+ asset_config_parser = asset_subparsers.add_parser("config", help="Create registry configuration file.")
282
+ asset_config_parser.add_argument("--registry-name", type=str, required=True, help="AzureML Registry name.")
283
+ asset_config_parser.add_argument("--subscription", type=str, required=True, help="Registry subscription ID.")
284
+ asset_config_parser.add_argument("-g", "--resource-group", type=str, required=True, help="Registry resource group.")
285
+ asset_config_parser.add_argument("--tenant-id", type=str, required=True, help="Registry Tenant ID.")
286
+ asset_config_parser.add_argument("-c", "--config-file", type=validate_registry_cfg, help="Registry config file path to write to (default: registry-mgmt.cfg).")
287
+ asset_config_parser.add_argument("--storage-name", type=str, help="Storage account name for storage overrides.")
288
+ asset_config_parser.add_argument("--container-name", type=str, help="Container name for storage overrides.")
289
+ asset_config_parser.add_argument("--container-path", type=str, help="Container path for storage overrides.")
290
+
291
+ # asset template command
292
+ asset_template_parser = asset_subparsers.add_parser("template", help="Create asset template files.")
293
+ _add_common_args(asset_template_parser, [dry_run_arg])
294
+ asset_template_parser.add_argument("--folder", type=Path, required=True, help="Path to the folder where asset template files will be created.")
295
+
238
296
  # show root command
239
297
  show_parser = subparsers.add_parser("show", help="Show syndication info.")
240
298
  _add_common_args(show_parser, [registry_name_arg, dry_run_arg])
@@ -272,6 +330,32 @@ def main() -> None:
272
330
  print(syndication_target_show(args.registry_name))
273
331
  elif args.target_subcommand == "set":
274
332
  syndication_target_set(args.registry_name, args.value, args.dry_run)
333
+ elif args.command == "asset":
334
+ if args.asset_subcommand == "validate":
335
+ # Config file is not needed for validation
336
+ asset_validate(args.asset_path, args.dry_run)
337
+ elif args.asset_subcommand == "deploy":
338
+ # Config file is required for deployment
339
+ asset_deploy(args.asset_path, args.config, args.dry_run)
340
+ elif args.asset_subcommand == "config":
341
+ # Validate storage parameters - all or none must be provided
342
+ storage_args = [args.storage_name, args.container_name, args.container_path]
343
+ if any(storage_args) and not all(storage_args):
344
+ parser.error("When using storage overrides, --storage-name, --container-name, and --container-path are all required.")
345
+
346
+ create_registry_config(
347
+ registry_name=args.registry_name,
348
+ subscription_id=args.subscription,
349
+ resource_group=args.resource_group,
350
+ tenant_id=args.tenant_id,
351
+ config_file_path=args.config_file,
352
+ storage_name=args.storage_name,
353
+ container_name=args.container_name,
354
+ container_path=args.container_path
355
+ )
356
+ elif args.asset_subcommand == "template":
357
+ # Create asset template files
358
+ asset_template(args.folder, args.dry_run)
275
359
  elif args.command == "show":
276
360
  print(show_command(args.registry_name, args.as_arm_object))
277
361
  else:
@@ -0,0 +1,4 @@
1
+ # ---------------------------------------------------------
2
+ # Copyright (c) Microsoft Corporation. All rights reserved.
3
+ # ---------------------------------------------------------
4
+ """This module is for asset content validation."""
@@ -0,0 +1,4 @@
1
+ extra_config: model.yaml
2
+ spec: spec.yaml
3
+ type: model
4
+ categories: [""] # include the author name
@@ -0,0 +1,3 @@
1
+ <!-- DO NOT CHANGE MARKDOWN HEADERS. IF CHANGED, MODEL CARD MAY BE REJECTED BY A REVIEWER -->
2
+
3
+ <!-- `description.md` is required. -->
@@ -0,0 +1,3 @@
1
+ <!-- DO NOT CHANGE MARKDOWN HEADERS. IF CHANGED, MODEL CARD MAY BE REJECTED BY A REVIEWER -->
2
+
3
+ <!-- `evaluation.md` is highly recommended, but not required. It captures information about the performance of the model. We highly recommend including this section as this information is often used to decide what model to use. -->
@@ -0,0 +1,61 @@
1
+ {
2
+ "type": "object",
3
+ "properties": {
4
+ "parents": {
5
+ "type": "array",
6
+ "items": {
7
+ "type": "object",
8
+ "properties": {
9
+ "assetId": {
10
+ "type": "string",
11
+ "pattern": "^azureml://registries/"
12
+ }
13
+ },
14
+ "required": [
15
+ "assetId"
16
+ ]
17
+ }
18
+ },
19
+ "variantMetadata": {
20
+ "type": "object",
21
+ "properties": {
22
+ "modelType": {
23
+ "type": "string",
24
+ "enum": ["", "ONNX"]
25
+ },
26
+ "quantization": {
27
+ "type": "array",
28
+ "items": {
29
+ "type": "string",
30
+ "enum": ["QuaRot", "W4Aint16", "AWQ", "RTN", "GPTQ"]
31
+ }
32
+ },
33
+ "device": {
34
+ "type": "string",
35
+ "enum": ["", "npu", "cpu", "gpu"]
36
+ },
37
+ "executionProvider": {
38
+ "type": "string"
39
+ },
40
+ "fileSizeBytes": {
41
+ "type": "integer"
42
+ },
43
+ "vRamFootprintBytes": {
44
+ "type": "integer"
45
+ }
46
+ },
47
+ "required": [
48
+ "modelType",
49
+ "quantization",
50
+ "device",
51
+ "executionProvider",
52
+ "fileSizeBytes",
53
+ "vRamFootprintBytes"
54
+ ]
55
+ }
56
+ },
57
+ "required": [
58
+ "parents",
59
+ "variantMetadata"
60
+ ]
61
+ }