azureml-registry-tools 0.1.0a12__py3-none-any.whl → 0.1.0a13__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/_cli/registry_syndication_cli.py +3 -1
- azureml/registry/data/validate_model_schema.py +49 -11
- azureml/registry/mgmt/asset_management.py +7 -4
- {azureml_registry_tools-0.1.0a12.dist-info → azureml_registry_tools-0.1.0a13.dist-info}/METADATA +1 -1
- {azureml_registry_tools-0.1.0a12.dist-info → azureml_registry_tools-0.1.0a13.dist-info}/RECORD +9 -9
- {azureml_registry_tools-0.1.0a12.dist-info → azureml_registry_tools-0.1.0a13.dist-info}/WHEEL +0 -0
- {azureml_registry_tools-0.1.0a12.dist-info → azureml_registry_tools-0.1.0a13.dist-info}/entry_points.txt +0 -0
- {azureml_registry_tools-0.1.0a12.dist-info → azureml_registry_tools-0.1.0a13.dist-info}/licenses/LICENSE.txt +0 -0
- {azureml_registry_tools-0.1.0a12.dist-info → azureml_registry_tools-0.1.0a13.dist-info}/top_level.txt +0 -0
@@ -350,6 +350,8 @@ def main() -> None:
|
|
350
350
|
asset_validate_parser = asset_subparsers.add_parser("validate", help="Validate an asset.")
|
351
351
|
_add_common_args(asset_validate_parser, [dry_run_arg])
|
352
352
|
asset_validate_parser.add_argument("--asset-path", type=Path, help="Path to the asset folder to validate.")
|
353
|
+
asset_validate_parser.add_argument("--allow-additional-properties", action="store_true",
|
354
|
+
help="Allow additional properties not defined in the schema")
|
353
355
|
|
354
356
|
# asset deploy command
|
355
357
|
asset_deploy_parser = asset_subparsers.add_parser("deploy", help="Deploy an asset to registry.")
|
@@ -447,7 +449,7 @@ def main() -> None:
|
|
447
449
|
elif args.command == "asset":
|
448
450
|
if args.asset_subcommand == "validate":
|
449
451
|
# Config file is not needed for validation
|
450
|
-
asset_validate(args.asset_path, args.dry_run)
|
452
|
+
asset_validate(args.asset_path, args.dry_run, args.allow_additional_properties)
|
451
453
|
elif args.asset_subcommand == "deploy":
|
452
454
|
# Config file is required for deployment
|
453
455
|
asset_deploy(args.asset_path, args.config, args.dry_run)
|
@@ -2,37 +2,71 @@
|
|
2
2
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
3
3
|
# ---------------------------------------------------------
|
4
4
|
|
5
|
-
"""Validate model
|
5
|
+
"""Validate model schema."""
|
6
6
|
|
7
7
|
import argparse
|
8
|
-
import yaml
|
9
|
-
import sys
|
10
8
|
import jsonschema
|
9
|
+
import sys
|
10
|
+
import yaml
|
11
|
+
|
11
12
|
from pathlib import Path
|
12
|
-
from typing import List
|
13
|
+
from typing import Any, Dict, List
|
13
14
|
|
14
15
|
import azureml.assets as assets
|
15
16
|
import azureml.assets.util as util
|
16
17
|
from azureml.assets.util import logger
|
17
18
|
|
18
19
|
|
20
|
+
def set_additional_properties_true(obj):
|
21
|
+
"""Recursively set additionalProperties to True in a schema object."""
|
22
|
+
if isinstance(obj, dict):
|
23
|
+
if "additionalProperties" in obj:
|
24
|
+
obj["additionalProperties"] = True
|
25
|
+
for v in obj.values():
|
26
|
+
set_additional_properties_true(v)
|
27
|
+
elif isinstance(obj, list):
|
28
|
+
for item in obj:
|
29
|
+
set_additional_properties_true(item)
|
30
|
+
|
31
|
+
|
32
|
+
def load_schema(schema_file: Path, allow_additional_properties: bool = False) -> Dict[str, Any]:
|
33
|
+
"""Load and optionally modify the schema to allow for additional properties.
|
34
|
+
|
35
|
+
Args:
|
36
|
+
schema_file (Path): Path to the schema file
|
37
|
+
allow_additional_properties (bool): Whether to allow additional properties not defined in the schema
|
38
|
+
|
39
|
+
Returns:
|
40
|
+
dict: Loaded model schema
|
41
|
+
"""
|
42
|
+
# Load schema from file
|
43
|
+
with open(schema_file, 'r') as file:
|
44
|
+
schema = yaml.safe_load(file)
|
45
|
+
|
46
|
+
if allow_additional_properties:
|
47
|
+
logger.print('Allowing for additional properties, setting "additionalProperties: true" in the model schema')
|
48
|
+
set_additional_properties_true(schema)
|
49
|
+
|
50
|
+
return schema
|
51
|
+
|
52
|
+
|
19
53
|
def validate_model_schema(input_dirs: List[Path],
|
20
54
|
schema_file: Path,
|
21
|
-
asset_config_filename: str
|
55
|
+
asset_config_filename: str,
|
56
|
+
allow_additional_properties: bool = False) -> bool:
|
22
57
|
"""Validate model variant schema.
|
23
58
|
|
24
59
|
Args:
|
25
60
|
input_dirs (List[Path]): Directories containing assets.
|
26
61
|
schema_file (Path): File containing model variant schema.
|
27
62
|
asset_config_filename (str): Asset config filename to search for.
|
63
|
+
allow_additional_properties (bool): Whether to allow additional properties not defined in schema.
|
28
64
|
|
29
65
|
Returns:
|
30
66
|
bool: True on success.
|
31
67
|
"""
|
32
68
|
# Load model schema from file
|
33
|
-
loaded_schema =
|
34
|
-
with open(schema_file, 'r') as file:
|
35
|
-
loaded_schema = yaml.safe_load(file)
|
69
|
+
loaded_schema = load_schema(schema_file, allow_additional_properties)
|
36
70
|
|
37
71
|
# Create validator instance for collecting all errors
|
38
72
|
validator = jsonschema.Draft7Validator(loaded_schema)
|
@@ -99,12 +133,15 @@ def validate_model_schema(input_dirs: List[Path],
|
|
99
133
|
|
100
134
|
if __name__ == "__main__":
|
101
135
|
# Handle command-line args
|
102
|
-
parser = argparse.ArgumentParser()
|
136
|
+
parser = argparse.ArgumentParser(description="Validate model specifications against JSON schema")
|
103
137
|
parser.add_argument("-i", "--input-dirs", required=True,
|
104
138
|
help="Comma-separated list of directories containing assets")
|
105
|
-
parser.add_argument("-m", "--schema-file", default=Path(__file__).parent / "model.schema.json", type=Path,
|
139
|
+
parser.add_argument("-m", "--schema-file", default=Path(__file__).parent / "model.schema.json", type=Path,
|
140
|
+
help="Model Schema file")
|
106
141
|
parser.add_argument("-a", "--asset-config-filename", default=assets.DEFAULT_ASSET_FILENAME,
|
107
142
|
help="Asset config file name to search for")
|
143
|
+
parser.add_argument("--allow-additional-properties", action="store_true",
|
144
|
+
help="Allow additional properties not defined in the schema")
|
108
145
|
args = parser.parse_args()
|
109
146
|
|
110
147
|
# Convert comma-separated values to lists
|
@@ -113,7 +150,8 @@ if __name__ == "__main__":
|
|
113
150
|
# Validate against model schema
|
114
151
|
success = validate_model_schema(input_dirs=input_dirs,
|
115
152
|
schema_file=args.schema_file,
|
116
|
-
asset_config_filename=args.asset_config_filename
|
153
|
+
asset_config_filename=args.asset_config_filename,
|
154
|
+
allow_additional_properties=args.allow_additional_properties)
|
117
155
|
|
118
156
|
if not success:
|
119
157
|
sys.exit(1)
|
@@ -39,11 +39,12 @@ from azureml.assets.publish_utils import create_asset # noqa: E402
|
|
39
39
|
from azureml.assets.validate_assets import validate_assets # noqa: E402
|
40
40
|
|
41
41
|
|
42
|
-
def validate_model(asset_path: Path) -> bool:
|
42
|
+
def validate_model(asset_path: Path, allow_additional_properties: bool = False) -> bool:
|
43
43
|
"""Validate model.
|
44
44
|
|
45
45
|
Args:
|
46
46
|
asset_path (Path): Path to the asset folder to validate
|
47
|
+
allow_additional_properties (bool): Whether to allow additional properties not defined in schema
|
47
48
|
|
48
49
|
Returns:
|
49
50
|
bool: True if validation passes, False otherwise
|
@@ -73,7 +74,8 @@ def validate_model(asset_path: Path) -> bool:
|
|
73
74
|
|
74
75
|
print("⚙️ [VALIDATION #3]: Validating model schema...")
|
75
76
|
if not validate_model_schema(input_dirs=[asset_path], schema_file=model_schema_file,
|
76
|
-
asset_config_filename=assets.DEFAULT_ASSET_FILENAME
|
77
|
+
asset_config_filename=assets.DEFAULT_ASSET_FILENAME,
|
78
|
+
allow_additional_properties=allow_additional_properties):
|
77
79
|
print("❌ [FAILED] Validation #3: validate_model_schema\n")
|
78
80
|
errors += 1
|
79
81
|
else:
|
@@ -193,12 +195,13 @@ def create_or_update_asset(readonly_asset: AssetConfig, config: RegistryConfig):
|
|
193
195
|
print(f" - Azure Portal link: https://ml.azure.com/registries/{config.registry_name}/models/{mutable_asset.name}/version/{mutable_asset.version}?tid={config.tenant_id}")
|
194
196
|
|
195
197
|
|
196
|
-
def asset_validate(asset_path: Path, dry_run: bool = False) -> bool:
|
198
|
+
def asset_validate(asset_path: Path, dry_run: bool = False, allow_additional_properties: bool = False) -> bool:
|
197
199
|
"""Validate an asset at the specified path.
|
198
200
|
|
199
201
|
Args:
|
200
202
|
asset_path (Path): Path to the asset folder to validate
|
201
203
|
dry_run (bool): If True, perform a dry run without side effects
|
204
|
+
allow_additional_properties (bool): Whether to allow additional properties not defined in schema
|
202
205
|
|
203
206
|
Returns:
|
204
207
|
bool: True if validation passes, False otherwise
|
@@ -231,7 +234,7 @@ def asset_validate(asset_path: Path, dry_run: bool = False) -> bool:
|
|
231
234
|
return False
|
232
235
|
|
233
236
|
# Perform validation
|
234
|
-
return validate_model(readonly_asset.file_path)
|
237
|
+
return validate_model(readonly_asset.file_path, allow_additional_properties)
|
235
238
|
|
236
239
|
|
237
240
|
def asset_deploy(asset_path: Path, config_path: Path, dry_run: bool = False) -> bool:
|
{azureml_registry_tools-0.1.0a12.dist-info → azureml_registry_tools-0.1.0a13.dist-info}/RECORD
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
azureml/__init__.py,sha256=_gYz_vABVrp9EyOZEYn4Ya8XotJC2rZn-b9kFTEj1Dk,266
|
2
2
|
azureml/registry/__init__.py,sha256=qjP86n1Yz6hdZb3az-wjfi7LNndsFjMQI6lXmKfXapM,266
|
3
3
|
azureml/registry/_cli/__init__.py,sha256=dJ020ynrregpUaNGu8xVLLmX3cC9DAjaBMP1qnljLEE,208
|
4
|
-
azureml/registry/_cli/registry_syndication_cli.py,sha256=
|
4
|
+
azureml/registry/_cli/registry_syndication_cli.py,sha256=ozx57mKjmgJ4ABULBjX8-0Y0bF8hIN_s1ukALdXrTVc,29228
|
5
5
|
azureml/registry/_cli/repo2registry_cli.py,sha256=4CDv4tYWLTjVgdXIcoKA9iu_gOv_Z_xn05wSANkdmdg,5378
|
6
6
|
azureml/registry/_rest_client/__init__.py,sha256=Eh0vB8AVlwkZlHLO4DCGHyyfRYYgeTeVjiUAX_WujG0,219
|
7
7
|
azureml/registry/_rest_client/arm_client.py,sha256=KVSj0V1bN-vCUV3fBbIdZDpWTLKYT6qdWIZtDjx2la4,4516
|
@@ -16,10 +16,10 @@ azureml/registry/data/model-variant.schema.json,sha256=AT4Dy6cCtp_SFUfSqYIqcER8A
|
|
16
16
|
azureml/registry/data/model.schema.json,sha256=2Ew3wt9QMzIBdLeIQXph0Fj7X8OqZJbzu_7-c4SEKZY,26062
|
17
17
|
azureml/registry/data/model.yaml.template,sha256=h5uqAN22FLaWrbPxIb8yVKH9cGDBrIwooXYYfsKhxDw,245
|
18
18
|
azureml/registry/data/notes.md.template,sha256=yFQ7qbrjlGDLZGuSoJUvQjctXsnCdoUd6txJuT-duCY,300
|
19
|
-
azureml/registry/data/validate_model_schema.py,sha256
|
19
|
+
azureml/registry/data/validate_model_schema.py,sha256=bcxeyAT0Cl-0WbpVj_AXpMPnkJbnRxAbNKODtE-kBJg,6884
|
20
20
|
azureml/registry/data/validate_model_variant_schema.py,sha256=JPVNtRBn6qciMu4PaRXOvS86OGGW0cocL2Rri4xYKo8,3629
|
21
21
|
azureml/registry/mgmt/__init__.py,sha256=LMhqcEC8ItmmpKZljElGXH-6olHlT3SLl0dJU01OvuM,226
|
22
|
-
azureml/registry/mgmt/asset_management.py,sha256=
|
22
|
+
azureml/registry/mgmt/asset_management.py,sha256=7U1QJZTS4bOnheKeyc5WUMCCsEeWMJAS5peTshT_Yzg,11129
|
23
23
|
azureml/registry/mgmt/create_asset_template.py,sha256=ejwLuIsmzJOoUePoxbM-eGMg2E3QHfdX-nPMBzYUVMQ,3525
|
24
24
|
azureml/registry/mgmt/create_manifest.py,sha256=N9wRmjAKO09A3utN_lCUsM_Ufpj7PL0SJz-XHPHWuyM,9528
|
25
25
|
azureml/registry/mgmt/create_model_spec.py,sha256=1PdAcUf-LomvljoT8wKQihXMTLd7DoTgN0qDX4Lol1A,10473
|
@@ -31,9 +31,9 @@ azureml/registry/tools/config.py,sha256=tjPaoBsWtPXBL8Ww1hcJtsr2SuIjPKt79dR8iovc
|
|
31
31
|
azureml/registry/tools/create_or_update_assets.py,sha256=Q-_BV7KWn1huQn5JriKT_8xJNoQQ_HK5wCftrq9DepA,15988
|
32
32
|
azureml/registry/tools/registry_utils.py,sha256=zgYlCiOONtQJ4yZ9wg8tKVoE8dh6rrjB8hYBGhpV9-0,1403
|
33
33
|
azureml/registry/tools/repo2registry_config.py,sha256=eXp_tU8Jyi30g8xGf7wbpLgKEPpieohBANKxMSLzq7s,4873
|
34
|
-
azureml_registry_tools-0.1.
|
35
|
-
azureml_registry_tools-0.1.
|
36
|
-
azureml_registry_tools-0.1.
|
37
|
-
azureml_registry_tools-0.1.
|
38
|
-
azureml_registry_tools-0.1.
|
39
|
-
azureml_registry_tools-0.1.
|
34
|
+
azureml_registry_tools-0.1.0a13.dist-info/licenses/LICENSE.txt,sha256=n20rxwp7_NGrrShv9Qvcs90sjI1l3Pkt3m-5OPCWzgs,845
|
35
|
+
azureml_registry_tools-0.1.0a13.dist-info/METADATA,sha256=ehMdSIszV-lZKkTKpf2IQMM_vNMB2uxvDHdZqN1BvEU,527
|
36
|
+
azureml_registry_tools-0.1.0a13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
37
|
+
azureml_registry_tools-0.1.0a13.dist-info/entry_points.txt,sha256=iRUkAeQidMnO6RQzpLqMUBTcyYtNzAfSin9WnSdVGLw,147
|
38
|
+
azureml_registry_tools-0.1.0a13.dist-info/top_level.txt,sha256=ZOeEa0TAXo6i5wOjwBoqfIGEuxOcKuscGgNSpizqREY,8
|
39
|
+
azureml_registry_tools-0.1.0a13.dist-info/RECORD,,
|
{azureml_registry_tools-0.1.0a12.dist-info → azureml_registry_tools-0.1.0a13.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|