| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
from __future__ import absolute_import, division, print_function |
| 6 |
__metaclass__ = type |
| 7 |
|
| 8 |
DOCUMENTATION = ''' |
| 9 |
--- |
| 10 |
module: azure_rm_ml_online_endpoint_invoke |
| 11 |
version_added: "3.18.0" |
| 12 |
short_description: Invoke ML Online Endpoint resources |
| 13 |
description: |
| 14 |
- Invoke ML Online Endpoint resources. |
| 15 |
options: |
| 16 |
name: |
| 17 |
description: |
| 18 |
- Name of the Azure ML online endpoint. |
| 19 |
required: true |
| 20 |
type: str |
| 21 |
deployment_name: |
| 22 |
description: |
| 23 |
- Name of the Azure ML Online deployment to target. |
| 24 |
required: false |
| 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 |
request_file: |
| 37 |
description: |
| 38 |
- Local path to the JSON file containing the request data. |
| 39 |
required: false |
| 40 |
type: str |
| 41 |
local: |
| 42 |
description: |
| 43 |
- Invoke all local endpoints. |
| 44 |
type: bool |
| 45 |
default: false |
| 46 |
|
| 47 |
extends_documentation_fragment: |
| 48 |
- azure.azcollection.azure |
| 49 |
|
| 50 |
author: |
| 51 |
- Bill Peck (@p3ck) |
| 52 |
''' |
| 53 |
|
| 54 |
EXAMPLES = ''' |
| 55 |
- name: Invoke ML Online Endpoint |
| 56 |
azure.azcollection.azure_rm_ml_online_endpoint_invoke: |
| 57 |
name: endpoint-command-ansible |
| 58 |
resource_group: myResourceGroup |
| 59 |
ml_workspace: myMLWorkspace |
| 60 |
request_file: ./targets/azure_rm_ml_online_deployment/files/sample-request.json |
| 61 |
''' |
| 62 |
|
| 63 |
RETURN = ''' |
| 64 |
changed: |
| 65 |
description: |
| 66 |
- Will return True if successfully invoked |
| 67 |
returned: always |
| 68 |
type: bool |
| 69 |
sample: true |
| 70 |
ml_online_endpoint_invoke: |
| 71 |
description: |
| 72 |
- Online Endpoint Invoked that match the name and deployment. |
| 73 |
returned: always |
| 74 |
type: dict |
| 75 |
sample: [11055.977245525679, 4503.079536107787] |
| 76 |
''' |
| 77 |
|
| 78 |
|
| 79 |
try: |
| 80 |
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common_ml import MLClientCommon |
| 81 |
except ImportError: |
| 82 |
|
| 83 |
pass |
| 84 |
|
| 85 |
|
| 86 |
class AzureRMMLOnlineEndpointInvoke(MLClientCommon): |
| 87 |
def __init__(self): |
| 88 |
|
| 89 |
self.module_arg_spec = dict( |
| 90 |
name=dict( |
| 91 |
type='str', |
| 92 |
required=True, |
| 93 |
), |
| 94 |
deployment_name=dict( |
| 95 |
type='str', |
| 96 |
required=False, |
| 97 |
), |
| 98 |
resource_group=dict( |
| 99 |
type='str', |
| 100 |
required=True, |
| 101 |
), |
| 102 |
ml_workspace=dict( |
| 103 |
type='str', |
| 104 |
required=True, |
| 105 |
), |
| 106 |
request_file=dict( |
| 107 |
type='str', |
| 108 |
required=False, |
| 109 |
), |
| 110 |
local=dict( |
| 111 |
type='bool', |
| 112 |
default=False, |
| 113 |
), |
| 114 |
) |
| 115 |
|
| 116 |
self._client = None |
| 117 |
self.ml_registry = None |
| 118 |
|
| 119 |
self.results = dict( |
| 120 |
changed=False, |
| 121 |
ml_online_endpoint_invoke=None |
| 122 |
) |
| 123 |
|
| 124 |
super(AzureRMMLOnlineEndpointInvoke, self).__init__(self.module_arg_spec, |
| 125 |
supports_tags=False, |
| 126 |
supports_check_mode=False, |
| 127 |
facts_module=True, |
| 128 |
) |
| 129 |
|
| 130 |
def exec_module(self, **kwargs): |
| 131 |
|
| 132 |
for key in list(self.module_arg_spec.keys()): |
| 133 |
setattr(self, key, kwargs[key]) |
| 134 |
|
| 135 |
input_data_asset = None |
| 136 |
|
| 137 |
ml_online_endpoint_invoke = self.client.online_endpoints.invoke( |
| 138 |
endpoint_name=self.name, |
| 139 |
request_file=self.request_file, |
| 140 |
input_data=input_data_asset, |
| 141 |
deployment_name=self.deployment_name, |
| 142 |
local=self.local, |
| 143 |
) |
| 144 |
|
| 145 |
self.results['changed'] = True |
| 146 |
self.results['ml_online_endpoint_invoke'] = ml_online_endpoint_invoke |
| 147 |
return self.results |
| 148 |
|
| 149 |
|
| 150 |
def main(): |
| 151 |
AzureRMMLOnlineEndpointInvoke() |
| 152 |
|
| 153 |
|
| 154 |
if __name__ == '__main__': |
| 155 |
main() |