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-payload
Create 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
Authorization
- Secret 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
main
ormaster
- Step Name: type
V7 incoming
- Payload Input Name: type
v7-payload
- Source Commit Reference: type the primary branch of your Valohai project in Git. This is usually either
-
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.
You can also launch a pipeline
While this guide just uses a simple execution that lets you inspect the data payload V7 is sending, a good next step is to bootstrap the creation of a pipeline by parsing the webhook payload into input files and parameters for further steps in a pipeline.
This allows reusing general purpose steps as only the entry point execution needs to know how V7 sends data payloads.
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
- Read 7labs docs about Webhook stages
- You can call the V7 API from inside your Valohai executions to report results back. See the V7labs docs for example code