azureml-registry-tools 0.1.0a4__py3-none-any.whl → 0.1.0a6__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 +53 -1
- azureml/registry/_rest_client/registry_management_client.py +1 -1
- azureml/registry/mgmt/syndication_manifest.py +76 -0
- {azureml_registry_tools-0.1.0a4.dist-info → azureml_registry_tools-0.1.0a6.dist-info}/METADATA +1 -1
- {azureml_registry_tools-0.1.0a4.dist-info → azureml_registry_tools-0.1.0a6.dist-info}/RECORD +9 -9
- {azureml_registry_tools-0.1.0a4.dist-info → azureml_registry_tools-0.1.0a6.dist-info}/WHEEL +0 -0
- {azureml_registry_tools-0.1.0a4.dist-info → azureml_registry_tools-0.1.0a6.dist-info}/entry_points.txt +0 -0
- {azureml_registry_tools-0.1.0a4.dist-info → azureml_registry_tools-0.1.0a6.dist-info}/licenses/LICENSE.txt +0 -0
- {azureml_registry_tools-0.1.0a4.dist-info → azureml_registry_tools-0.1.0a6.dist-info}/top_level.txt +0 -0
@@ -3,10 +3,12 @@
|
|
3
3
|
# ---------------------------------------------------------
|
4
4
|
import argparse
|
5
5
|
import json
|
6
|
+
import sys
|
7
|
+
from uuid import UUID
|
6
8
|
from azureml.registry._rest_client.registry_management_client import RegistryManagementClient
|
7
9
|
from azureml.registry._rest_client.arm_client import ArmClient
|
8
10
|
from azureml.registry.mgmt.create_manifest import generate_syndication_manifest
|
9
|
-
from azureml.registry.mgmt.syndication_manifest import SyndicationManifest
|
11
|
+
from azureml.registry.mgmt.syndication_manifest import SyndicationManifest, ResyncAssetsInManifestDto
|
10
12
|
|
11
13
|
|
12
14
|
def syndication_manifest_show(registry_name: str) -> dict:
|
@@ -56,6 +58,31 @@ def syndication_manifest_delete(registry_name: str, dry_run: bool) -> None:
|
|
56
58
|
RegistryManagementClient(registry_name=registry_name).delete_manifest()
|
57
59
|
|
58
60
|
|
61
|
+
def syndication_manifest_sync(registry_name: str, manifest_value: str, tenant_id: str, asset_ids: list, dry_run: bool) -> None:
|
62
|
+
"""Sync assets in the syndication manifest for the specified registry.
|
63
|
+
|
64
|
+
Args:
|
65
|
+
registry_name (str): Name of the AzureML registry.
|
66
|
+
manifest_value (str): Manifest value as a string (JSON).
|
67
|
+
tenant_id (str): Tenant ID to use for all assets.
|
68
|
+
asset_ids (list): List of asset IDs to sync.
|
69
|
+
dry_run (bool): If True, do not perform any changes.
|
70
|
+
"""
|
71
|
+
if manifest_value:
|
72
|
+
# for inline manifest value allow different casing of keys
|
73
|
+
sync_dto = ResyncAssetsInManifestDto.from_dict(json.loads(manifest_value), normalize_keys=True)
|
74
|
+
else:
|
75
|
+
# Create from tenant ID and asset IDs
|
76
|
+
sync_dto = ResyncAssetsInManifestDto.from_asset_list(UUID(tenant_id), asset_ids)
|
77
|
+
|
78
|
+
dto = sync_dto.to_dict()
|
79
|
+
if dry_run:
|
80
|
+
print(f"Dry run: Would sync assets for registry {registry_name} with data: {json.dumps(dto, indent=2)}")
|
81
|
+
else:
|
82
|
+
client = RegistryManagementClient(registry_name=registry_name)
|
83
|
+
client.sync_assets_in_manifest(dto)
|
84
|
+
|
85
|
+
|
59
86
|
def syndication_target_show(registry_name: str) -> object:
|
60
87
|
"""Show the current syndication target(s) for the specified registry and region.
|
61
88
|
|
@@ -129,6 +156,12 @@ def main() -> None:
|
|
129
156
|
# Delete the current manifest
|
130
157
|
registry-mgmt syndication manifest delete --registry-name myreg
|
131
158
|
|
159
|
+
# Sync assets from a JSON value
|
160
|
+
registry-mgmt syndication manifest sync --registry-name myreg --value '{"AssetsToResync": [...]}'
|
161
|
+
|
162
|
+
# Sync assets from tenant ID and asset list
|
163
|
+
registry-mgmt syndication manifest sync --registry-name myreg --tenant-id "12345678-1234-1234-1234-123456789012" --asset-ids asset1 asset2 asset3
|
164
|
+
|
132
165
|
# Show the current target
|
133
166
|
registry-mgmt syndication target show --registry-name myreg
|
134
167
|
|
@@ -184,6 +217,13 @@ def main() -> None:
|
|
184
217
|
manifest_delete_parser = manifest_subparsers.add_parser("delete", help="Delete the current manifest.")
|
185
218
|
_add_common_args(manifest_delete_parser, [registry_name_arg, dry_run_arg])
|
186
219
|
|
220
|
+
manifest_sync_parser = manifest_subparsers.add_parser("sync", help="Sync assets in the manifest.")
|
221
|
+
_add_common_args(manifest_sync_parser, [registry_name_arg, dry_run_arg])
|
222
|
+
sync_group = manifest_sync_parser.add_mutually_exclusive_group(required=True)
|
223
|
+
sync_group.add_argument("-v", "--value", type=str, help="Manifest sync value as JSON string.")
|
224
|
+
sync_group.add_argument("-t", "--tenant-id", type=str, help="Tenant ID to use for all assets.")
|
225
|
+
manifest_sync_parser.add_argument("-a", "--asset-ids", type=str, nargs="+", help="List of asset IDs to sync (only valid with --tenant-id).")
|
226
|
+
|
187
227
|
# syndication target
|
188
228
|
target_parser = synd_subparsers.add_parser("target", help="Manage syndication target.")
|
189
229
|
target_subparsers = target_parser.add_subparsers(dest="target_subcommand", required=True)
|
@@ -215,6 +255,18 @@ def main() -> None:
|
|
215
255
|
syndication_manifest_delete(args.registry_name, args.dry_run)
|
216
256
|
else:
|
217
257
|
print("Manifest deletion cancelled.")
|
258
|
+
elif args.manifest_subcommand == "sync":
|
259
|
+
# Validate constraints for sync command
|
260
|
+
if args.tenant_id and not args.asset_ids:
|
261
|
+
print("Error: --asset-ids is required when using --tenant-id", file=sys.stderr)
|
262
|
+
sys.exit(1)
|
263
|
+
elif args.asset_ids and not args.tenant_id:
|
264
|
+
print("Error: --asset-ids can only be used with --tenant-id", file=sys.stderr)
|
265
|
+
sys.exit(1)
|
266
|
+
elif not args.value and not args.tenant_id:
|
267
|
+
print("Error: Either --value or --tenant-id must be specified", file=sys.stderr)
|
268
|
+
sys.exit(1)
|
269
|
+
syndication_manifest_sync(args.registry_name, args.value, args.tenant_id, args.asset_ids, args.dry_run)
|
218
270
|
elif args.synd_subcommand == "target":
|
219
271
|
if args.target_subcommand == "show":
|
220
272
|
print(syndication_target_show(args.registry_name))
|
@@ -57,7 +57,7 @@ class RegistryManagementClient(BaseAzureRestClient):
|
|
57
57
|
response = self.post(url, json=manifest_dto)
|
58
58
|
return response.json()
|
59
59
|
|
60
|
-
def
|
60
|
+
def sync_assets_in_manifest(self, resync_assets_dto: dict) -> dict:
|
61
61
|
"""
|
62
62
|
Resynchronize assets in the syndication manifest.
|
63
63
|
|
@@ -148,3 +148,79 @@ class SyndicationManifest:
|
|
148
148
|
tenant_id=tenant_id,
|
149
149
|
source_registries=source_registries
|
150
150
|
)
|
151
|
+
|
152
|
+
|
153
|
+
@dataclass
|
154
|
+
class AssetToResync:
|
155
|
+
"""Represents an asset to resync with its associated tenant ID."""
|
156
|
+
|
157
|
+
asset_id: str
|
158
|
+
tenant_id: UUID
|
159
|
+
|
160
|
+
def to_dict(self) -> dict:
|
161
|
+
"""Convert the AssetToResync instance to a dictionary."""
|
162
|
+
return {
|
163
|
+
"AssetIds": self.asset_id,
|
164
|
+
"TenantId": str(self.tenant_id)
|
165
|
+
}
|
166
|
+
|
167
|
+
@staticmethod
|
168
|
+
def from_dict(d: dict, normalize_keys=False) -> "AssetToResync":
|
169
|
+
"""Create an AssetToResync instance from a dictionary."""
|
170
|
+
asset_id = _get_key(d, "AssetIds", "asset_ids", normalize_keys=normalize_keys)
|
171
|
+
if asset_id is None:
|
172
|
+
raise ValueError("Missing required field 'AssetIds' in dictionary.")
|
173
|
+
|
174
|
+
tenant_id_str = _get_key(d, "TenantId", "tenant_id", normalize_keys=normalize_keys)
|
175
|
+
if tenant_id_str is None:
|
176
|
+
raise ValueError("Missing required field 'TenantId' in dictionary.")
|
177
|
+
|
178
|
+
try:
|
179
|
+
tenant_id = UUID(str(tenant_id_str))
|
180
|
+
except ValueError:
|
181
|
+
raise ValueError("TenantId must be a valid UUID string.")
|
182
|
+
|
183
|
+
return AssetToResync(
|
184
|
+
asset_id=str(asset_id),
|
185
|
+
tenant_id=tenant_id
|
186
|
+
)
|
187
|
+
|
188
|
+
|
189
|
+
@dataclass
|
190
|
+
class ResyncAssetsInManifestDto:
|
191
|
+
"""Represents a collection of assets to resync in a manifest."""
|
192
|
+
|
193
|
+
assets_to_resync: List[AssetToResync]
|
194
|
+
|
195
|
+
def to_dict(self) -> dict:
|
196
|
+
"""Convert the ResyncAssetsInManifestDto instance to a dictionary."""
|
197
|
+
return {
|
198
|
+
"AssetsToResync": [asset.to_dict() for asset in self.assets_to_resync]
|
199
|
+
}
|
200
|
+
|
201
|
+
@staticmethod
|
202
|
+
def from_dict(d: dict, normalize_keys=False) -> "ResyncAssetsInManifestDto":
|
203
|
+
"""Create a ResyncAssetsInManifestDto instance from a dictionary."""
|
204
|
+
assets_list = _get_key(d, "AssetsToResync", "assets_to_resync", normalize_keys=normalize_keys)
|
205
|
+
if not isinstance(assets_list, list):
|
206
|
+
raise ValueError("AssetsToResync must be a list.")
|
207
|
+
return ResyncAssetsInManifestDto(
|
208
|
+
assets_to_resync=[AssetToResync.from_dict(asset, normalize_keys=normalize_keys) for asset in assets_list]
|
209
|
+
)
|
210
|
+
|
211
|
+
@staticmethod
|
212
|
+
def from_asset_list(tenant_id: UUID, asset_ids: List[str]) -> "ResyncAssetsInManifestDto":
|
213
|
+
"""Create a ResyncAssetsInManifestDto instance from a tenant ID and list of asset ID strings.
|
214
|
+
|
215
|
+
Args:
|
216
|
+
tenant_id (UUID): The tenant ID to use for all assets.
|
217
|
+
asset_ids (List[str]): List of asset ID strings.
|
218
|
+
|
219
|
+
Returns:
|
220
|
+
ResyncAssetsInManifestDto: Instance with assets created from the provided IDs and tenant ID.
|
221
|
+
"""
|
222
|
+
assets_to_resync = [
|
223
|
+
AssetToResync(asset_id=asset_id, tenant_id=tenant_id)
|
224
|
+
for asset_id in asset_ids
|
225
|
+
]
|
226
|
+
return ResyncAssetsInManifestDto(assets_to_resync=assets_to_resync)
|
{azureml_registry_tools-0.1.0a4.dist-info → azureml_registry_tools-0.1.0a6.dist-info}/RECORD
RENAMED
@@ -1,23 +1,23 @@
|
|
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=3PpXkq0EF6-adCMnz6HDALeugqfS9l86oIvh4isZyvw,12962
|
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
|
8
8
|
azureml/registry/_rest_client/base_rest_client.py,sha256=JcmhckfR-ZdUtEh0EeQIKfe63Zjowa1fLzmVeWpeLno,8173
|
9
|
-
azureml/registry/_rest_client/registry_management_client.py,sha256=
|
9
|
+
azureml/registry/_rest_client/registry_management_client.py,sha256=3-PBwj91lkG1yrlB-s7jaYj0w5j177oSHZHvcoO8icQ,4984
|
10
10
|
azureml/registry/mgmt/__init__.py,sha256=LMhqcEC8ItmmpKZljElGXH-6olHlT3SLl0dJU01OvuM,226
|
11
11
|
azureml/registry/mgmt/create_manifest.py,sha256=N9wRmjAKO09A3utN_lCUsM_Ufpj7PL0SJz-XHPHWuyM,9528
|
12
|
-
azureml/registry/mgmt/syndication_manifest.py,sha256=
|
12
|
+
azureml/registry/mgmt/syndication_manifest.py,sha256=8Sfd49QuCA5en5_mIOLE21kZVpnReUXowx_g0TVRgWg,9025
|
13
13
|
azureml/registry/tools/__init__.py,sha256=IAuWWpGfZm__pAkBIxmpJz84QskpkxBr0yDk1TUSnkE,223
|
14
14
|
azureml/registry/tools/config.py,sha256=tjPaoBsWtPXBL8Ww1hcJtsr2SuIjPKt79dR8iovcebg,3639
|
15
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.0a6.dist-info/licenses/LICENSE.txt,sha256=n20rxwp7_NGrrShv9Qvcs90sjI1l3Pkt3m-5OPCWzgs,845
|
19
|
+
azureml_registry_tools-0.1.0a6.dist-info/METADATA,sha256=cHaW5YddH_-oZuk3WdrCjAH5xTaFKcKZZDWuBpj-B0A,521
|
20
|
+
azureml_registry_tools-0.1.0a6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
21
|
+
azureml_registry_tools-0.1.0a6.dist-info/entry_points.txt,sha256=iRUkAeQidMnO6RQzpLqMUBTcyYtNzAfSin9WnSdVGLw,147
|
22
|
+
azureml_registry_tools-0.1.0a6.dist-info/top_level.txt,sha256=ZOeEa0TAXo6i5wOjwBoqfIGEuxOcKuscGgNSpizqREY,8
|
23
|
+
azureml_registry_tools-0.1.0a6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
{azureml_registry_tools-0.1.0a4.dist-info → azureml_registry_tools-0.1.0a6.dist-info}/top_level.txt
RENAMED
File without changes
|