aboutsummaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/azure/ai/ml/_schema/compute/custom_applications.py
blob: 66fa587c5b0f72899a93ca83f51507f993cd7c09 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

# pylint: disable=unused-argument
from marshmallow import fields
from marshmallow.decorators import post_load

from azure.ai.ml._schema.core.fields import NestedField, StringTransformedEnum
from azure.ai.ml._schema.core.schema_meta import PatchedSchemaMeta
from azure.ai.ml.constants._compute import CustomApplicationDefaults


class ImageSettingsSchema(metaclass=PatchedSchemaMeta):
    reference = fields.Str()

    @post_load
    def make(self, data, **kwargs):
        from azure.ai.ml.entities._compute._custom_applications import ImageSettings

        return ImageSettings(**data)


class EndpointsSettingsSchema(metaclass=PatchedSchemaMeta):
    target = fields.Int()
    published = fields.Int()

    @post_load
    def make(self, data, **kwargs):
        from azure.ai.ml.entities._compute._custom_applications import EndpointsSettings

        return EndpointsSettings(**data)


class VolumeSettingsSchema(metaclass=PatchedSchemaMeta):
    source = fields.Str()
    target = fields.Str()

    @post_load
    def make(self, data, **kwargs):
        from azure.ai.ml.entities._compute._custom_applications import VolumeSettings

        return VolumeSettings(**data)


class CustomApplicationsSchema(metaclass=PatchedSchemaMeta):
    name = fields.Str(required=True)
    type = StringTransformedEnum(allowed_values=[CustomApplicationDefaults.DOCKER])
    image = NestedField(ImageSettingsSchema)
    endpoints = fields.List(NestedField(EndpointsSettingsSchema))
    environment_variables = fields.Dict()
    bind_mounts = fields.List(NestedField(VolumeSettingsSchema))

    @post_load
    def make(self, data, **kwargs):
        from azure.ai.ml.entities._compute._custom_applications import (
            CustomApplications,
        )

        return CustomApplications(**data)