Trigger Example with V7
Integrate V7 labeling workflows with Valohai
You can integrate model annotation workflows from V7 Labs with Valohai using webhooks.
Configuration on Valohai
You will need a step configured in your project to be launched as a V7 webhook is received. Here's an example configuration and code:
Add this step to your valohai.yaml:
- step:
name: V7 incoming
image: python:3.11
command:
- pip install valohai-utils
- python ./v7_request.py
inputs:
- name: v7-payloadCreate a file named v7_request.py, with this code:
import json
import valohai
with open(valohai.inputs("v7-payload").path()) as payload_f:
payload = json.load(payload_f)
print("Got this data from V7:")
print(json.dumps(payload, indent=4))We can now create a new Webhook Trigger in your Project settings -> Triggers -> Create Trigger
You will need to create and write down a unique secret token to authorize the webhook request. Your password manager can create and manage this secret, or you can choose this value freely.
For Trigger Type, select Webhook
Using the condition column's + Add menu, add a Web Request Authentication condition
Type: select "Static Token"
Token Lookup Namespace: select "HTTP Header"
Token Lookup Key: type
AuthorizationSecret Key: put the unique secret token
Value Prefix: type
token=
Using the action column's + Add menu, add a Run Execution action
Source Commit Reference: type the primary branch of your Valohai project in Git. This is usually either
mainormasterStep Name: type
V7 incomingPayload Input Name: type
v7-payload
Click on Save Trigger
You are now on the Triggers list again. Select the
...menu of the trigger we just created, and select "Edit" to return to editing the trigger. Get the trigger URL and save it to your notes.
Configuration on V7
Webhooks are represented on V7 as Webhook stages in a workflow.
Navigate to your workflow, create a webhook stage, and connect it to the rest of the workflow:
URL: paste the webhook URL we created above
Authorization header: type:
token=<paste unique secret token here>Check Include annotation data
You can now click the "Test" button to check that it's all wired up and an execution is launched on Valohai
V7 will now automatically launch your step on Valohai once the workflow reaches the Webhook stage.
Next steps
You can call the V7 API from inside your Valohai executions to report results back. See the V7labs docs for example code
Last updated
Was this helpful?
