66
77from os import PathLike
88from pathlib import Path
9- from typing import IO , AnyStr , List , Dict , Optional , Union
10-
11-
12- from azure .ai .ml ._restclient .v2023_02_01_preview .models import (
13- PackageRequest ,
14- PackageResponse ,
15- ModelPackageInput as RestModelPackageInput ,
16- PackageInputPathId as RestPackageInputPathId ,
17- PackageInputPathVersion as RestPackageInputPathVersion ,
18- PackageInputPathUrl as RestPackageInputPathUrl ,
19- CodeConfiguration ,
20- )
21-
22- from azure .ai .ml .entities ._resource import Resource
9+ from typing import IO , AnyStr , Dict , List , Optional , Union
10+
11+ from azure .ai .ml ._restclient .v2023_02_01_preview .models import CodeConfiguration
12+ from azure .ai .ml ._restclient .v2023_02_01_preview .models import ModelPackageInput as RestModelPackageInput
13+ from azure .ai .ml ._restclient .v2023_02_01_preview .models import PackageInputPathId as RestPackageInputPathId
14+ from azure .ai .ml ._restclient .v2023_02_01_preview .models import PackageInputPathUrl as RestPackageInputPathUrl
15+ from azure .ai .ml ._restclient .v2023_02_01_preview .models import PackageInputPathVersion as RestPackageInputPathVersion
16+ from azure .ai .ml ._restclient .v2023_02_01_preview .models import PackageRequest , PackageResponse
2317from azure .ai .ml ._schema .assets .package .model_package import ModelPackageSchema
24- from azure .ai .ml .entities ._util import load_from_dict
25- from azure .ai .ml .constants ._common import (
26- BASE_PATH_CONTEXT_KEY ,
27- PARAMS_OVERRIDE_KEY ,
28- )
29- from azure .ai .ml ._utils .utils import snake_to_pascal , dump_yaml_to_file
3018from azure .ai .ml ._utils ._experimental import experimental
31- from .model_configuration import ModelConfiguration
32- from .inferencing_server import AzureMLOnlineInferencingServer , AzureMLBatchInferencingServer
19+ from azure .ai .ml ._utils .utils import dump_yaml_to_file , snake_to_pascal
20+ from azure .ai .ml .constants ._common import BASE_PATH_CONTEXT_KEY , PARAMS_OVERRIDE_KEY
21+ from azure .ai .ml .entities ._resource import Resource
22+ from azure .ai .ml .entities ._util import load_from_dict
23+
3324from .base_environment_source import BaseEnvironment
25+ from .inferencing_server import AzureMLBatchInferencingServer , AzureMLOnlineInferencingServer
26+ from .model_configuration import ModelConfiguration
3427
3528
3629@experimental
3730class PackageInputPathId :
31+ """Package input path specified with a resource ID.
3832
39- """Package input path specified with a resource id.
40-
41- :param input_path_type: The type of the input path. Possible values include: "Url", "PathId", "PathVersion".
42- :type input_path_type: str
43- :param resource_id: The resource id of the input path. e.g. azureml://subscriptions/<>/resourceGroups/
44- <>/providers/Microsoft.MachineLearningServices/workspaces/<>/data/<>/versions/<>
45- :type resource_id: str
33+ :param input_path_type: The type of the input path. Accepted values are "Url", "PathId", and "PathVersion".
34+ :type input_path_type: Optional[str]
35+ :param resource_id: The resource ID of the input path. e.g. "azureml://subscriptions/<>/resourceGroups/
36+ <>/providers/Microsoft.MachineLearningServices/workspaces/<>/data/<>/versions/<>".
37+ :type resource_id: Optional[str]
4638 """
4739
48- def __init__ (self , * , input_path_type : Optional [str ] = None , resource_id : Optional [str ] = None ):
40+ def __init__ (self , * , input_path_type : Optional [str ] = None , resource_id : Optional [str ] = None ) -> None :
4941 self .input_path_type = input_path_type
5042 self .resource_id = resource_id
5143
@@ -67,12 +59,12 @@ def _from_rest_object(cls, package_input_path_id_rest_object: RestPackageInputPa
6759class PackageInputPathVersion :
6860 """Package input path specified with a resource name and version.
6961
70- :param input_path_type: The type of the input path. Possible values include: "Url", "PathId", "PathVersion".
71- :type input_path_type: str
62+ :param input_path_type: The type of the input path. Accepted values are "Url", "PathId", and "PathVersion".
63+ :type input_path_type: Optional[ str]
7264 :param resource_name: The resource name of the input path.
73- :type resource_name: str
65+ :type resource_name: Optional[ str]
7466 :param resource_version: The resource version of the input path.
75- :type resource_version: str
67+ :type resource_version: Optional[ str]
7668 """
7769
7870 def __init__ (
@@ -81,7 +73,7 @@ def __init__(
8173 input_path_type : Optional [str ] = None ,
8274 resource_name : Optional [str ] = None ,
8375 resource_version : Optional [str ] = None ,
84- ):
76+ ) -> None :
8577 self .input_path_type = input_path_type
8678 self .resource_name = resource_name
8779 self .resource_version = resource_version
@@ -108,14 +100,14 @@ def _from_rest_object(
108100class PackageInputPathUrl :
109101 """Package input path specified with a url.
110102
111- :param input_path_type: The type of the input path. Possible values include: "Url", "PathId", "PathVersion".
112- :type input_path_type: str
113- :param url: The url of the input path. e.g. azureml://subscriptions/<>/resourceGroups/
114- <>/providers/Microsoft.MachineLearningServices/workspaces/data/<>/versions/<>
115- :type url: str
103+ :param input_path_type: The type of the input path. Accepted values are "Url", "PathId", and "PathVersion".
104+ :type input_path_type: Optional[ str]
105+ :param url: The url of the input path. e.g. " azureml://subscriptions/<>/resourceGroups/
106+ <>/providers/Microsoft.MachineLearningServices/workspaces/data/<>/versions/<>".
107+ :type url: Optional[ str]
116108 """
117109
118- def __init__ (self , * , input_path_type : Optional [str ] = None , url : Optional [str ] = None ):
110+ def __init__ (self , * , input_path_type : Optional [str ] = None , url : Optional [str ] = None ) -> None :
119111 self .input_path_type = input_path_type
120112 self .url = url
121113
@@ -138,14 +130,14 @@ class ModelPackageInput:
138130 """Model package input.
139131
140132 :param type: The type of the input.
141- :type type: str
133+ :type type: Optional[ str]
142134 :param path: The path of the input.
143- :type path: azure.ai.ml.entities.PackageInputPathId
144- or azure.ai.ml.entities.PackageInputPathUrl or azure.ai.ml.entities.PackageInputPathVersion
145- :param mode: The mode of the input.
146- :type mode: str
147- :param mount_path: The mount path of the input.
148- :type mount_path: str
135+ :type path: Optional[Union[~ azure.ai.ml.entities.PackageInputPathId, ~azure.ai.ml.entities.PackageInputPathUrl,
136+ ~ azure.ai.ml.entities.PackageInputPathVersion]]
137+ :param mode: The input mode .
138+ :type mode: Optional[ str]
139+ :param mount_path: The mount path for the input.
140+ :type mount_path: Optional[ str]
149141 """
150142
151143 def __init__ (
@@ -155,7 +147,7 @@ def __init__(
155147 path : Optional [Union [PackageInputPathId , PackageInputPathUrl , PackageInputPathVersion ]] = None ,
156148 mode : Optional [str ] = None ,
157149 mount_path : Optional [str ] = None ,
158- ):
150+ ) -> None :
159151 self .type = type
160152 self .path = path
161153 self .mode = mode
@@ -183,22 +175,23 @@ def _from_rest_object(cls, model_package_input_rest_object: RestModelPackageInpu
183175class ModelPackage (Resource , PackageRequest ):
184176 """Model package.
185177
186- :param target_environment_name: The name of the model package.
178+ :param target_environment_name: The target environment name for the model package.
187179 :type target_environment_name: str
188180 :param inferencing_server: The inferencing server of the model package.
189- :type inferencing_server: azure.ai.ml.entities.InferencingServer
181+ :type inferencing_server: Union[~azure.ai.ml.entities.AzureMLOnlineInferencingServer,
182+ ~azure.ai.ml.entities.AzureMLBatchInferencingServer]
190183 :param base_environment_source: The base environment source of the model package.
191- :type base_environment_source: azure.ai.ml.entities.BaseEnvironmentSource
184+ :type base_environment_source: Optional[~ azure.ai.ml.entities.BaseEnvironment]
192185 :param target_environment_version: The version of the model package.
193- :type target_environment_version: str
186+ :type target_environment_version: Optional[ str]
194187 :param environment_variables: The environment variables of the model package.
195- :type environment_variables: dict
188+ :type environment_variables: Optional[ dict[str, str]]
196189 :param inputs: The inputs of the model package.
197- :type inputs: list[azure.ai.ml.entities.ModelPackageInput]
198- :param model_configuration: The model configuration of the model package .
199- :type model_configuration: azure.ai.ml.entities.ModelConfiguration
190+ :type inputs: Optional[ list[~ azure.ai.ml.entities.ModelPackageInput] ]
191+ :param model_configuration: The model configuration.
192+ :type model_configuration: Optional[~ azure.ai.ml.entities.ModelConfiguration]
200193 :param tags: The tags of the model package.
201- :type tags: dict
194+ :type tags: Optiona[ dict[str, str]]
202195 """
203196
204197 def __init__ (
@@ -212,7 +205,7 @@ def __init__(
212205 inputs : Optional [List [ModelPackageInput ]] = None ,
213206 model_configuration : Optional [ModelConfiguration ] = None ,
214207 tags : Optional [Dict [str , str ]] = None ,
215- ):
208+ ) -> None :
216209 super ().__init__ (
217210 name = target_environment_name ,
218211 target_environment_name = target_environment_name ,
@@ -246,12 +239,16 @@ def dump(
246239 dest : Union [str , PathLike , IO [AnyStr ]],
247240 ** kwargs , # pylint: disable=unused-argument
248241 ) -> None :
249- """Dump the model package spec into a file in yaml format.
250-
251- :param dest: Either
252- * A path to a local file
253- * A writeable file-like object
254- :type dest: Union[str, PathLike, IO[AnyStr]]
242+ """Dumps the job content into a file in YAML format.
243+
244+ :param dest: The local path or file stream to write the YAML content to.
245+ If dest is a file path, a new file will be created.
246+ If dest is an open file, the file will be written to directly.
247+ :type dest: Union[PathLike, str, IO[AnyStr]]
248+ :param kwargs: Additional arguments to pass to the YAML serializer.
249+ :type kwargs: Optional[dict]
250+ :raises FileExistsError: Raised if dest is a file path and the file already exists.
251+ :raises IOError: Raised if dest is an open file and the file is not writable.
255252 """
256253 yaml_serialized = self ._to_dict ()
257254 dump_yaml_to_file (dest , yaml_serialized , default_flow_style = False )
0 commit comments