about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry
diff options
context:
space:
mode:
Diffstat (limited to '.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry')
-rw-r--r--.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/__init__.py9
-rw-r--r--.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/registry.py53
-rw-r--r--.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/registry_region_arm_details.py61
-rw-r--r--.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/system_created_acr_account.py35
-rw-r--r--.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/system_created_storage_account.py40
-rw-r--r--.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/util.py15
6 files changed, 213 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/__init__.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/__init__.py
new file mode 100644
index 00000000..9c2fe189
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/__init__.py
@@ -0,0 +1,9 @@
+# ---------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# ---------------------------------------------------------
+
+__path__ = __import__("pkgutil").extend_path(__path__, __name__)  # type: ignore
+
+from .registry import RegistrySchema
+
+__all__ = ["RegistrySchema"]
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/registry.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/registry.py
new file mode 100644
index 00000000..17233195
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/registry.py
@@ -0,0 +1,53 @@
+# ---------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# ---------------------------------------------------------
+
+from marshmallow import fields
+
+from azure.ai.ml._schema.core.fields import DumpableStringField, NestedField, StringTransformedEnum, UnionField
+from azure.ai.ml._schema.core.intellectual_property import PublisherSchema
+from azure.ai.ml._schema.core.resource import ResourceSchema
+from azure.ai.ml._schema.workspace.identity import IdentitySchema
+from azure.ai.ml._utils.utils import snake_to_pascal
+from azure.ai.ml.constants._common import PublicNetworkAccess
+from azure.ai.ml.constants._registry import AcrAccountSku
+from azure.ai.ml.entities._registry.registry_support_classes import SystemCreatedAcrAccount
+
+from .registry_region_arm_details import RegistryRegionDetailsSchema
+from .system_created_acr_account import SystemCreatedAcrAccountSchema
+from .util import acr_format_validator
+
+
+# Based on 10-01-preview api
+class RegistrySchema(ResourceSchema):
+    # Inherits name, id, tags, and description fields from ResourceSchema
+
+    # Values from RegistryTrackedResource (Client name: Registry)
+    location = fields.Str(required=True)
+
+    # Values from Registry (Client name: RegistryProperties)
+    public_network_access = StringTransformedEnum(
+        allowed_values=[PublicNetworkAccess.DISABLED, PublicNetworkAccess.ENABLED],
+        casing_transform=snake_to_pascal,
+    )
+    replication_locations = fields.List(NestedField(RegistryRegionDetailsSchema))
+    intellectual_property = NestedField(PublisherSchema)
+    # This is an acr account which will be applied to every registryRegionArmDetail defined
+    # in replication_locations. This is different from the internal swagger
+    # definition, which has a per-region list of acr accounts.
+    # Per-region acr account configuration is NOT possible through yaml configs for now.
+    container_registry = UnionField(
+        [DumpableStringField(validate=acr_format_validator), NestedField(SystemCreatedAcrAccountSchema)],
+        required=False,
+        is_strict=True,
+        load_default=SystemCreatedAcrAccount(acr_account_sku=AcrAccountSku.PREMIUM),
+    )
+
+    # Values that can only be set by return values from the system, never
+    # set by the user.
+    identity = NestedField(IdentitySchema, dump_only=True)
+    kind = fields.Str(dump_only=True)
+    sku = fields.Str(dump_only=True)
+    managed_resource_group = fields.Str(dump_only=True)
+    mlflow_registry_uri = fields.Str(dump_only=True)
+    discovery_url = fields.Str(dump_only=True)
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/registry_region_arm_details.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/registry_region_arm_details.py
new file mode 100644
index 00000000..c861b94c
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/registry_region_arm_details.py
@@ -0,0 +1,61 @@
+# ---------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# ---------------------------------------------------------
+
+# pylint: disable=unused-argument
+
+from marshmallow import ValidationError, fields, post_load, pre_dump
+
+from azure.ai.ml._schema.core.fields import DumpableStringField, NestedField, UnionField
+from azure.ai.ml._schema.core.schema_meta import PatchedSchemaMeta
+from azure.ai.ml._utils._experimental import experimental
+from azure.ai.ml.constants._registry import StorageAccountType
+from azure.ai.ml.entities._registry.registry_support_classes import SystemCreatedStorageAccount
+
+from .system_created_storage_account import SystemCreatedStorageAccountSchema
+from .util import storage_account_validator
+
+
+# Differs from the swagger def in that the acr_details can only be supplied as a
+# single registry-wide instance, rather than a per-region list.
+@experimental
+class RegistryRegionDetailsSchema(metaclass=PatchedSchemaMeta):
+    # Commenting this out for the time being.
+    # We do not want to surface the acr_config as a per-region configurable
+    # field. Instead we want to simplify the UX and surface it as a non-list,
+    # top-level value called 'container_registry'.
+    # We don't even want to show the per-region acr accounts when displaying a
+    # registry to the user, so this isn't even left as a dump-only field.
+    """acr_config = fields.List(
+        UnionField(
+            [DumpableStringField(validate=acr_format_validator), NestedField(SystemCreatedAcrAccountSchema)],
+            dump_only=True,
+            is_strict=True,
+        )
+    )"""
+    location = fields.Str()
+    storage_config = UnionField(
+        [
+            NestedField(SystemCreatedStorageAccountSchema),
+            fields.List(DumpableStringField(validate=storage_account_validator)),
+        ],
+        is_strict=True,
+        load_default=SystemCreatedStorageAccount(
+            storage_account_hns=False, storage_account_type=StorageAccountType.STANDARD_LRS
+        ),
+    )
+
+    @post_load
+    def make(self, data, **kwargs):
+        from azure.ai.ml.entities import RegistryRegionDetails
+
+        data.pop("type", None)
+        return RegistryRegionDetails(**data)
+
+    @pre_dump
+    def predump(self, data, **kwargs):
+        from azure.ai.ml.entities import RegistryRegionDetails
+
+        if not isinstance(data, RegistryRegionDetails):
+            raise ValidationError("Cannot dump non-RegistryRegionDetails object into RegistryRegionDetailsSchema")
+        return data
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/system_created_acr_account.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/system_created_acr_account.py
new file mode 100644
index 00000000..08b78c2e
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/system_created_acr_account.py
@@ -0,0 +1,35 @@
+# ---------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# ---------------------------------------------------------
+
+# pylint: disable=unused-argument
+
+from marshmallow import ValidationError, fields, post_load, pre_dump
+
+from azure.ai.ml._schema import StringTransformedEnum
+from azure.ai.ml._schema.core.schema_meta import PatchedSchemaMeta
+from azure.ai.ml._utils._experimental import experimental
+from azure.ai.ml.constants._registry import AcrAccountSku
+
+
+@experimental
+class SystemCreatedAcrAccountSchema(metaclass=PatchedSchemaMeta):
+    arm_resource_id = fields.Str(dump_only=True)
+    acr_account_sku = StringTransformedEnum(
+        allowed_values=[sku.value for sku in AcrAccountSku], casing_transform=lambda x: x.lower()
+    )
+
+    @post_load
+    def make(self, data, **kwargs):
+        from azure.ai.ml.entities import SystemCreatedAcrAccount
+
+        data.pop("type", None)
+        return SystemCreatedAcrAccount(**data)
+
+    @pre_dump
+    def predump(self, data, **kwargs):
+        from azure.ai.ml.entities import SystemCreatedAcrAccount
+
+        if not isinstance(data, SystemCreatedAcrAccount):
+            raise ValidationError("Cannot dump non-SystemCreatedAcrAccount object into SystemCreatedAcrAccountSchema")
+        return data
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/system_created_storage_account.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/system_created_storage_account.py
new file mode 100644
index 00000000..cdbbcd67
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/system_created_storage_account.py
@@ -0,0 +1,40 @@
+# ---------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# ---------------------------------------------------------
+
+# pylint: disable=unused-argument
+
+from marshmallow import ValidationError, fields, post_load, pre_dump
+
+from azure.ai.ml._schema import StringTransformedEnum
+from azure.ai.ml._schema.core.schema_meta import PatchedSchemaMeta
+from azure.ai.ml.constants._registry import StorageAccountType
+
+
+class SystemCreatedStorageAccountSchema(metaclass=PatchedSchemaMeta):
+    arm_resource_id = fields.Str(dump_only=True)
+    storage_account_hns = fields.Bool(load_default=False)
+    storage_account_type = StringTransformedEnum(
+        load_default=StorageAccountType.STANDARD_LRS,
+        allowed_values=[accountType.value for accountType in StorageAccountType],
+        casing_transform=lambda x: x.lower(),
+    )
+    replication_count = fields.Int(load_default=1, validate=lambda count: count > 0)
+    replicated_ids = fields.List(fields.Str(), dump_only=True)
+
+    @post_load
+    def make(self, data, **kwargs):
+        from azure.ai.ml.entities import SystemCreatedStorageAccount
+
+        data.pop("type", None)
+        return SystemCreatedStorageAccount(**data)
+
+    @pre_dump
+    def predump(self, data, **kwargs):
+        from azure.ai.ml.entities import SystemCreatedStorageAccount
+
+        if not isinstance(data, SystemCreatedStorageAccount):
+            raise ValidationError(
+                "Cannot dump non-SystemCreatedStorageAccount object into SystemCreatedStorageAccountSchema"
+            )
+        return data
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/util.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/util.py
new file mode 100644
index 00000000..19c01e9a
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/registry/util.py
@@ -0,0 +1,15 @@
+# ---------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# ---------------------------------------------------------
+
+# Simple helper methods to avoid re-using lambda's everywhere
+
+from azure.ai.ml.constants._registry import ACR_ACCOUNT_FORMAT, STORAGE_ACCOUNT_FORMAT
+
+
+def storage_account_validator(storage_id: str):
+    return STORAGE_ACCOUNT_FORMAT.match(storage_id) is not None
+
+
+def acr_format_validator(acr_id: str):
+    return ACR_ACCOUNT_FORMAT.match(acr_id) is not None