Debian Codegraph @

ansible_collections/azure/azcollection/plugins/modules/azure_rm_ml_batch_endpoint_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_endpoint_info
11 version_added: "3.18.0"
12 short_description: List ML Batch Endpoint resources
13 description:
14 - List ML Batch Endpoint resources.
15 options:
16 name:
17 description:
18 - Name of the Azure ML batch endpoint.
19 type: str
20 required: false
21 resource_group:
22 description:
23 - Name of resource group.
24 required: true
25 type: str
26 ml_workspace:
27 description:
28 - Name of the Azure ML workspace.
29 required: true
30 type: str
31
32 extends_documentation_fragment:
33 - azure.azcollection.azure
34
35 author:
36 - Bill Peck (@p3ck)
37 '''
38
39 EXAMPLES = '''
40 - name: Get Specific ML Batch Endpoint by name
41 azure.azcollection.azure_rm_ml_batch_endpoint_info:
42 name: endpoint-command-xxxxxxxxxx
43 resource_group: myResourceGroup
44 ml_workspace: myMLWorkspace
45
46 - name: List ML Batch Endpoints
47 azure.azcollection.azure_rm_ml_batch_endpoint_info:
48 resource_group: myResourceGroup
49 ml_workspace: myMLWorkspace
50 '''
51
52 RETURN = '''
53 ml_batch_endpoints:
54 description:
55 - Batch Endpoints that match the query.
56 returned: always
57 type: dict
58 sample: [
59 {
60 "auth_mode": "aad_token",
61 "defaults": {
62 "deployment_name": "deployment-xxxxxxxxxx-ansible"
63 },
64 "description": "A hello world endpoint for component deployments.",
65 "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_endpoint_invoke/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/batchEndpoints/endpoint-xxxxxxxxxx-ansible",
66 "jobs": [
67 {
68 "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_endpoint_invoke/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/batchEndpoints/endpoint-xxxxxxxxxx-ansible/deployments/deployment-xxxxxxxxxx-ansible/jobs/pipelinejob-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
69 "name": "pipelinejob-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
70 "properties": {
71 "compute": {
72 "is_local": false
73 },
74 "interaction_endpoints": {
75 "Studio": {
76 "endpoint": "https://ml.azure.com/runs/pipelinejob-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx?wsid=/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/xxxxx-ml-batch_endpoint_invoke/workspaces/workspace-xxxxxxxxxx",
77 "job_endpoint_type": "Studio"
78 },
79 "Tracking": {
80 "endpoint": "azureml://eastus.api.azureml.ms/mlflow/v1.0/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_endpoint_invoke/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx?",
81 "job_endpoint_type": "Tracking"
82 }
83 },
84 "name": "honest_grape_xxxxxxxx",
85 "output": {
86 "datastore_id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_endpoint_invoke/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/datastores/workspaceartifactstore",
87 "path": "ExperimentRun/dcid.xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
88 },
89 "output_data": {
90 "score": {
91 "job_output_type": "UriFile",
92 "mode": "ReadWriteMount",
93 "uri": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_endpoint_invoke/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/datastores/workspaceblobstore/paths/azureml/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/score/predictions.csv"
94 }
95 },
96 "properties": {
97 "azureml.DatasetAccessMode": "Asset",
98 "azureml.DevPlatv2": "true",
99 "azureml.SourceComponentId": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_endpoint_invoke/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/components/hello_batch/versions/1",
100 "azureml.continue_on_failed_optional_input": "True",
101 "azureml.continue_on_step_failure": "True",
102 "azureml.defaultComputeName": "batch-cluster",
103 "azureml.defaultDataStoreName": "workspaceblobstore",
104 "azureml.deploymentname": "deployment-xxxxxxxxxx-ansible",
105 "azureml.endpointname": "endpoint-xxxxxxxxxx-ansible",
106 "azureml.enforceRerun": "False",
107 "azureml.parameters": "{}",
108 "azureml.pipelineComponent": "pipelinerun",
109 "azureml.pipelines.stages": "{\\"Initialization\\":null,\\"Execution\\":{\\"StartTime\\":\\"2026-05-04T13:51:04.3564364+00:00\\",\\"EndTime\\":\\"2026-05-04T13:55:32.6682006+00:00\\",\\"Status\\":\\"Finished\\"}}",
110 "azureml.runLineageType": "batchDeployment",
111 "azureml.runsource": "azureml.PipelineRun",
112 "azureml.sourcepipelinerunid": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
113 "runSource": "BatchDeployment",
114 "runType": "HTTP"
115 },
116 "provisioning_state": "Succeeded",
117 "status": "Completed",
118 "tags": {
119 "azureml.batchrun": "true",
120 "azureml.deploymentname": "deployment-xxxxxxxxxx-ansible",
121 "azureml.jobtype": "azureml.pipelinejob"
122 }
123 },
124 "system_data": {
125 "created_at": "2026-05-04T13:51:03.171352Z",
126 "created_by": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
127 "last_modified_at": "2026-05-04T13:55:32.837426Z",
128 "last_modified_by": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
129 },
130 "type": "Microsoft.MachineLearningServices/workspaces/batchEndpoints/deployments/jobs"
131 }
132 ],
133 "location": "eastus",
134 "name": "endpoint-xxxxxxxxxx-ansible",
135 "properties": {
136 "BatchEndpointCreationApiVersion": "2023-10-01",
137 "azureml.onlineendpointid": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxx-ml-batch_endpoint_invoke/providers/Microsoft.MachineLearningServices/workspaces/workspace-xxxxxxxxxx/batchEndpoints/endpoint-xxxxxxxxxx-ansible"
138 },
139 "provisioning_state": "Succeeded",
140 "scoring_uri": "https://endpoint-xxxxxxxxxx-ansible.eastus.inference.ml.azure.com/jobs",
141 "tags": {}
142 }
143 ]
144 ''' # NOQA
145
146
147 try:
148 from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ml import MLClientCommon
149 from azure.core.exceptions import ResourceNotFoundError
150 except ImportError:
151 # This is handled in azure_rm_common
152 pass
153
154
155 class AzureRMMLBatchEndpointInfo(MLClientCommon):
156 def __init__(self):
157
158 self.module_arg_spec = dict(
159 name=dict(
160 type='str',
161 required=False,
162 ),
163 resource_group=dict(
164 type='str',
165 required=True,
166 ),
167 ml_workspace=dict(
168 type='str',
169 required=True,
170 ),
171 )
172
173 self._client = None
174 self.ml_registry = None
175
176 self.results = dict(
177 ml_batch_endpoints=[]
178 )
179
180 super(AzureRMMLBatchEndpointInfo, self).__init__(self.module_arg_spec,
181 supports_tags=False,
182 supports_check_mode=True,
183 facts_module=True,
184 )
185
186 def exec_module(self, **kwargs):
187
188 for key in list(self.module_arg_spec.keys()):
189 setattr(self, key, kwargs[key])
190
191 if self.name:
192 ml_batch_endpoints = [self.get(self.name)]
193 else:
194 results = self.client.batch_endpoints.list()
195 ml_batch_endpoints = [self.get(x.name) for x in results]
196
197 self.results['ml_batch_endpoints'] = ml_batch_endpoints
198 return self.results
199
200 def get(self, name):
201 try:
202 result = self.client.batch_endpoints.get(name=name)
203 ml_batch_endpoint = self.entity_to_dict(result)
204 jobs = [self.entity_to_dict(x) for x in self.client.batch_endpoints.list_jobs(endpoint_name=name)]
205 ml_batch_endpoint['jobs'] = jobs
206 except ResourceNotFoundError:
207 ml_batch_endpoint = None
208
209 return ml_batch_endpoint
210
211
212 def main():
213 AzureRMMLBatchEndpointInfo()
214
215
216 if __name__ == '__main__':
217 main()