You can schedule triggers to happen automatically with a recurring period.
Scheduling basics
You have to choose “Scheduled” as the trigger type (it is the default) and add a Scheduled (cron)
condition to the trigger. The condition allows you to choose from either simple recurring choices (daily, weekdays,
weekly, etc.) or set a custom recurrence with a crontab
expression. You can utilize tools like cronmaker to
help create advanced crontab expressions.
Scheduled triggers launch no earlier than the expressed time in the condition, and no more frequently than once a minute. A scheduled trigger with no condition will never launch.
If multiple conditions are selected, the trigger will launch only if all conditions apply at the same time.
Quickstart example
Add the following step to your valohai.yaml
configuration file, create the requested file, commit the changes,
push them to Git and fetch the new commit to Valohai.
Create a file called scheduled.py
:
import valohai
import datetime
valohai.prepare(
step="Scheduled Execution",
)
month_day = datetime.datetime.now().strftime("%-d %b")
print(f"Today is {month_day}")
Add this step to your valohai.yaml
:
- step:
name: Scheduled Execution
image: python:3.11
command:
- pip install valohai-utils
- python ./scheduled.py
We can now define the webhook trigger. Go to Project settings -> open Triggers tab -> create New Trigger
- For Trigger Type, select Scheduled
-
Using the condition column’s + Add menu, add a Scheduled (Cron) condition with the following information:
- Select “On Weekdays”
- Select “12:00”
-
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
- Execution Step Name: type “Scheduled Execution”
- Execution Title: type “Daily execution at 12 UTC”
- Source Commit Reference: type the primary branch of your Valohai project in Git. This is usually either
-
Click on Save trigger
The trigger will automatically launch at the given day and time.