Pipelines
Pipelines are a core concept in Phaedra, as they are the “glue” that bind data processing steps together in an automated fashion. While they are entirely optional, and you can perform each step manually, you will save a lot of time and effort by using pipelines, especially in large-volume projects or assays.
But before a pipeline can be used, it must be set up correctly, a task which requires some knowledge about the Phaedra system and some careful configuration. This section describes the more technical details of pipeline setup.
The Pipeline Model
Pipelines have some evident properties such as a name, description, version number, etc. But at the heart of the pipeline model lies the definition, which is expressed as a JSON document.
For more information about the JSON syntax, see:
The pipeline definition describes a series of steps, where each step consists of a trigger and an action.
- The trigger describes the event that should initiate the execution of the current step.
- The action describes what should be done when the step gets executed.
However, you’ll find that many steps actually omit the trigger part. This is because most actions have an implicit trigger that fires automatically when the action is complete. The notable exception is the first step, which must always have an explicit trigger.
Consider the definition below:
{
"steps": [
{
"trigger": {
"type": "MeasurementCaptured",
"config": {
"pattern": ".*Barcode1234.*"
}
},
"action": {
"type": "LinkPlateMeasurement",
"config": {
"projectId": 500
}
}
},
{
"action": {
"type": "LinkPlateDefinition",
"config": {
"name": "My 8 x 12 Layout"
}
}
},
{
"action": {
"type": "CalculateProtocol",
"config": {
"id": 200
}
}
}
]
}
The first step contains both a trigger (MeasurementCaptured
) and an action (LinkPlateMeasurement
).
This is pretty straightforward: whenever a new measurement is captured into Phaedra whose name matches the given pattern, a new pipeline execution will begin for this pipeline.
The first thing that will happen in this execution, is that the new measurement will be linked to a plate in the project with ID 500. More details about the LinkPlateMeasurement
action
can be found further down in this document.
The second step does not have an explicit trigger. This means that the step will be invoked automatically when the action of the previous step (LinkPlateMeasurement
) is completed.
At that moment, action LinkPlateDefinition
is invoked, taking the name of a layout definition (My 8 x 12 Layout
) as a parameter.
The third and last step also uses an implicit trigger, and invokes the CalculateProtocol
action with protocol ID 200 as soon as the previous step’s LinkPlateDefinition
action is completed.
Pipeline Execution Variables
During pipeline execution, variables are obtained and stored, to be passed on and used between the different steps of the pipeline.
For example, the MeasurementCaptured
trigger will automatically capture two variables: barcode
and measurementId
, both obtained from the new measurement that was captured.
These variables are available to all subsequent triggers and actions of the pipeline, so that they can know which measurement is being dealt with.
Similarly, the LinkPlateMeasurement
action will capture an additional variable plateId
, referencing the plate that the measurement was linked to.
Available Trigger Types
When designing a new pipeline, you can choose between several trigger types to start off pipeline execution.
MeasurementCaptured
This is a trigger that fires whenever a measurement gets captured by the Phaedra’s DataCapture system.
Configuration | Description |
---|---|
pattern |
A regular expression that will be matched to the source path of the captured measurement. If the pattern does not match, the trigger will not fire. |
Event
This is a generic trigger that can fire whenever a Kafka event is received matching certain conditions. Please note that this is a more advanced trigger type.
Configuration | Description |
---|---|
topic |
The name of the Kafka topic that should be listened to. Events from other topics will be ignore. |
key |
The key of the Kafka event that should fire the trigger. Events with a different key will be ignored. |
value |
The value that must match the Kafka message in order to fire the trigger. |
pattern |
A regular expression that can be used instead of a literal value (see value above) to match the Kafka message. |
selector |
An optional JSON selector that can be used to select a substring of the Kafka message, if it is a JSON message. |
Available Action Types
Below is a list of available action types you can choose from when building a pipeline. The same action type can be used repeatedly in a pipeline.
Each action type will list, in addition to its available configuration settings, a list of required variables. These variables should be made available
by preceding steps. For example, using the MeasurementCaptured
trigger ensures the required variables for the LinkPlateMeasurementAction
action
will be available. If any required variables are not available at the time of execution, the execution will fail with an error message.
LinkPlateMeasurementAction
This action will link a measurement to a plate whose barcode matches the measurement’s.
Configuration | Description |
---|---|
projectId |
The ID of the project to find a matching plate in to link with. |
experimentNamePattern |
A regular expression that will be matched against the measurement source path and should contain at least one group, which captures the experiment name to use. |
experimentNamePatternGroup |
The number of the group in the experimentNamePattern that captures the experiment name. Defaults to 1 . |
createExperiment |
Set to "true" to auto-create an experiment if no experiment is found that matches the experiment name (determined using experimentNamePattern ). |
createPlate |
Set to "true" to auto-create a plate if no plate is found matching the measurement barcode in the target experiment. |
Required Variables | Description |
---|---|
barcode |
The barcode of the measurement, a plate with a matching barcode will be searched for. |
measurementId |
The ID of the measurement that will be linked to the plate. |
LinkPlateDefinitionAction
This action will link a plate with a plate definition.
Configuration | Description |
---|---|
source |
The source of the plate definition. Default value: template . |
name |
The name that identifies the plate definition in its source. |
Required Variables | Description |
---|---|
plateId |
The ID of the plate the plate definition will be linked with. |
CalculateProtocolAction
This action will execute a protocol on a plate.
Configuration | Description |
---|---|
id |
The ID of the protocol that should be executed. |
Required Variables | Description |
---|---|
plateId |
The ID of the plate that should be calculated. |
measurementId |
The ID of the measurement that is linked to the plate and should be used for calculation. |