The deployed workbench model provides a dedicated API for interaction.
To test the deployed workflow or integrate it with a custom application,
use the following endpoint schema to communicate with the deployed workflows.
In the Cloudera console, click the Cloudera AI tile. The
Cloudera AI Home page displays.
Click on the name of the workbench. The Cloudera AI Workbench
Home page displays.
Click Model Deployments in the left navigation pane.
The Models page displays.
Click a Model Name from the list. The
Overview page displays for the selected model. You can
see the Input field for the Test
Model section.
The deployed workbench model has its own API. To test or integrate the
deployed workflow, use the endpoint schema below to interact with it. Requests
are sent directly to the model endpoint using supported APIs ("action types").
The following code snippet is an example of a payload used to initiate a
workflow
task:
MODEL_ENDPOINT = "https://modelservice.<CDSW_DOMAIN>/model?accessKey=<ACCESS_KEY>"
CDSW_APIV2_KEY = "..." # An API key used for authorization to the model endpoint
# Defined during workflow task creation
workflow_inputs = {
"input1": "value_1"
}
inputs_encoded = base64.b64encode(json.dumps(workflow_inputs).encode("utf-8")).decode("utf-8")
payload = {
"action_type": "kickoff",
"kickoff_inputs": inputs_encoded
}
resp = requests.post(
MODEL_ENDPOINT,
json={
"request": payload
},
headers={"authorization": f"Bearer {CDSW_APIV2_KEY}", "Content-Type": "application/json"},
)
out = resp.json()
trace_id = out["response"]["trace_id"]
# This trace ID can be used to extract events from the Operations & Metrics server
print("trace_id: ", trace_id)