Debian Codegraph @

ansible_collections/azure/azcollection/plugins/modules/azure_rm_ml_batch_deployment_info.py

raw symbols SCIP
1 #!/usr/bin/python
2 #
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 from __future__ import absolute_import, division, print_function
6 __metaclass__ = type
7
8 DOCUMENTATION = '''
9 ---
10 module: azure_rm_ml_batch_deployment_info
11 version_added: "3.18.0"
12 short_description: List ML Batch Deployment resources
13 description:
14 - List ML Batch Deployment resources.
15 options:
16 name:
17 description:
18 - Name of the deployment.
19 type: str
20 required: false
21 endpoint_name:
22 description:
23 - Name of the endpoint.
24 required: true
25 type: str
26 resource_group:
27 description:
28 - Name of resource group.
29 required: true
30 type: str
31 ml_workspace:
32 description:
33 - Name of the Azure ML workspace.
34 required: true
35 type: str
36
37 extends_documentation_fragment:
38 - azure.azcollection.azure
39
40 author:
41 - Bill Peck (@p3ck)
42 '''
43
44 EXAMPLES = '''
45 - name: Get Specific ML Batch Deployment by name
46 azure.azcollection.azure_rm_ml_batch_deployment_info:
47 name: deployment-command-xxxxxxxxxx
48 endpoint_name: endpoint-command-xxxxxxxxxx
49 resource_group: myResourceGroup
50 ml_workspace: myMLWorkspace
51
52 - name: List ML Batch Deployments
53 azure.azcollection.azure_rm_ml_batch_deployment_info:
54 endpoint_name: endpoint-command-xxxxxxxxxx
55 resource_group: myResourceGroup
56 ml_workspace: myMLWorkspace
57 '''
58
59 RETURN = '''
60 ml_batch_deployments:
61 description:
62 - Batch Deployments that match the query.
63 returned: always
64 type: dict
65 sample: [
66 {
67 "creation_context": {
68 "created_at": "2026-04-24T15:39:01.058441+00:00",
69 "created_by": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
70 "last_modified_at": "2026-04-24T15:39:01.058431+00:00"
71 },
72 "endpoint_name": "endpoint-command-ansible",
73 "environment_variables": {},
74 "error_threshold": 0,
75 "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_deployment/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/batchEndpoints/endpoint-command-ansible/deployments/deployment-command-xxxxxxxxxx",
76 "jobs": [],
77 "logging_level": "Info",
78 "max_concurrency_per_instance": 0,
79 "mini_batch_size": 0,
80 "name": "deployment-command-xxxxxxxxxx",
81 "output_action": "summary_only",
82 "properties": {
83 "componentDeployment.Settings.continue_on_step_failure": null,
84 "default_compute": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_deployment/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/computes/batch-cluster",
85 "default_datastore": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_deployment/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/datastores/workspaceblobstore",
86 "deployment_configuration_type": "PipelineComponent"
87 },
88 "provisioning_state": "Succeeded",
89 "resources": {
90 "instance_count": 1,
91 "properties": {}
92 },
93 "retry_settings": {
94 "max_retries": 0,
95 "timeout": 0
96 },
97 "tags": {
98 "PipelineDeployment.ComponentId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_deployment/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/components/hello_batch/versions/1"
99 }
100 }
101 ]
102 ''' # NOQA
103
104
105 try:
106 from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ml import MLClientCommon
107 from azure.core.exceptions import ResourceNotFoundError
108 except ImportError:
109 # This is handled in azure_rm_common
110 pass
111
112
113 class AzureRMMLBatchDeploymentInfo(MLClientCommon):
114 def __init__(self):
115
116 self.module_arg_spec = dict(
117 name=dict(
118 type='str',
119 required=False,
120 ),
121 endpoint_name=dict(
122 type='str',
123 required=True,
124 ),
125 resource_group=dict(
126 type='str',
127 required=True,
128 ),
129 ml_workspace=dict(
130 type='str',
131 required=True,
132 ),
133 )
134
135 self._client = None
136 self.ml_registry = None
137
138 self.results = dict(
139 ml_batch_deployments=[]
140 )
141
142 super(AzureRMMLBatchDeploymentInfo, self).__init__(self.module_arg_spec,
143 supports_tags=False,
144 supports_check_mode=True,
145 facts_module=True,
146 )
147
148 def exec_module(self, **kwargs):
149
150 for key in list(self.module_arg_spec.keys()):
151 setattr(self, key, kwargs[key])
152
153 if self.name:
154 ml_batch_deployments = [self.get(self.name,
155 endpoint_name=self.endpoint_name)]
156 else:
157 results = self.client.batch_deployments.list(endpoint_name=self.endpoint_name)
158 ml_batch_deployments = [
159 self.get(x.name,
160 endpoint_name=self.endpoint_name)
161 for x in results]
162
163 self.results['ml_batch_deployments'] = ml_batch_deployments
164 return self.results
165
166 def get(self, name, endpoint_name=None):
167 try:
168 result = self.client.batch_deployments.get(name=name,
169 endpoint_name=endpoint_name)
170 ml_batch_deployment = self.entity_to_dict(result)
171 results = self.client.batch_deployments.list_jobs(
172 name=name,
173 endpoint_name=endpoint_name
174 )
175 ml_batch_deployment['jobs'] = [self.entity_to_dict(deployment)
176 for deployment in results]
177 except ResourceNotFoundError:
178 ml_batch_deployment = None
179
180 return ml_batch_deployment
181
182
183 def main():
184 AzureRMMLBatchDeploymentInfo()
185
186
187 if __name__ == '__main__':
188 main()