Trigger

A trigger defines how and when pipelines are executed automatically.

Trigger defines rules to executes automatically pipelines, ensuring that processes run efficiently without manual intervention.

Trigger can be created from User Interface in Design section or using the API. They play a crucial role in automating workflows by specifying conditions under which pipelines are initiated.
Note that once triggers are set to execute a pipeline automatically, they cannot be modified using the API within that context.

Triggers can be based on various conditions such as time intervals and delays and custom properties, providing flexibility and control over the execution of pipelines. This automation capability enhances productivity and ensures timely data processing and analysis.


Interval & Delay

Triggers support scheduled executions, a trigger will execute a pipeline at specific intervals of time.

Each interval are normally aligned to 0 days 0 hours 0 minutes 0 seconds and 0 milliseconds. An interval of 10 minutes for example, will trigger at 0h10, 0h20, 0h30 etc …

You can add a delay to it in milliseconds, e.g. 300000 ms or 5 minutes will triggers at 0h05, 0h15, 0h25, etc …

# partial example to create a trigger
trigger = wizata_dsapi.Trigger()
trigger.interval = 600000
trigger.delay = 300000
# other fields
wizata_dapi.api().create(trigger)

Triggers are made so timestamps are perfectly aligned regardless when the trigger is created or started. Pipeline Execution created from the trigger will have a sharp queued date. The queued date is by default used as now timestamp defining query relatives date.

When creating a trigger using the platform interface, there is also an option to add the previously explained delay/interval.

Figure 1. Adding an interval and delay to trigger

Figure 1. Adding an interval and delay to trigger



Template

Triggers must reference the pipeline to execute automatically, if your pipeline is templated you should also specify it on your triggers. That way it is set on generated executions and also ease the selection of twins.

# example to update the trigger template and pipeline
trigger = wizata_dsapi.api().fetch(id=uuid.UUID("your-id") , entity="triggers")
trigger.pipelineId = uuid.UUID("your-pipeline-id")
trigger.templateId = uuid.UUID("your-template-id")
wizata_dapi.api().update(trigger)

Properties

You can define fixed properties to pass to your Pipeline execution through the Triggers properties field.

trigger.properties = {
    "key" : "value"
}

This JSON dictionary can also be passed inside the Properties field inside the trigger creation using the user interface.

Figure 2. Adding a property JSON field inside a trigger.

Figure 2. Adding a property JSON field inside a trigger.

Twins

You might specify, while using a templated pipeline, all registered twins on which you would like to execute the triggers. At each interval elapsing, the triggering service will create an execution for each twin properly registered on the pipeline.

trigger.twin_ids = [
    "your-twin-id1" , "your-twin-id2"
]

Sample

Here is a complete example of a Trigger creation using the Wizata DSAPI Python toolkit:

trigger = wizata_dsapi.Trigger()
trigger.interval = 600000
trigger.delay = 300000
trigger.pipelineId = '12bf7b2f-e791-4d98-86c6-19ada0274012'
trigger.templateId = '1da299e3-8bfe-4688-9779-bd43ea28060b'
trigger.properties = {
    "from": "now-30d",
    "to": "now"
}
trigger.twin_ids = [
    "48d07d92-df8c-49fb-9df7-ca6621f35c8c" , "cf3dd6b7-cce2-4b8b-b1bd-169552362dfa"
]
wizata_dapi.api().create(trigger)

We can also recreate the same example using the user interface platform:

Figure 3. Example of a trigger creation.

Figure 3. Example of a trigger creation.