Runtime Parameters
Overview
This section details the process of defining parameters in a workflow that can then be set by a user when starting a run.
Parameters are variable values in a workflow that a user does not want to ‘hardcode’ in the workflow definition but instead wants to define them when going through the process of starting a run on LINQ.
An example would be defining a boolean parameter that determines if a labware would undergo a specific task or not.
Defining Parameters
Parameters can only be used in task arguments.
Four different parameter types can be defined: Boolean, Float, Integer and String parameters. See each class definition below.
Tip
String parameters can also be used to parameterize file paths.
Here are some example parameter definitions:
from linq.parameters import (
BooleanParameterDefinition,
FloatParameterDefinition,
StringParameterDefinition
)
cold_plate_temperature = FloatParameterDefinition(
id="cold_plate_temperature",
name="Cold Plate Temperature",
default=10.0,
)
centrifuge_option = BooleanParameterDefinition(
id="scan_barcode",
name="Scan Barcode",
default=False
)
method_file_path = StringParameterDefinition(
id="method_file_path",
name="Method File Path",
is_file_path=True,
)
For workflow tasks to access parameters, the parameter definitions need to be defined (in a list) as an argument in the workflow object
workflow = Workflow(
...
parameter_definitions=[cold_plate_temperature, centrifuge_option, method_file_path]
)
These parameters can then be used in the inputs argument of a task by referencing the desired parameter id
incubate_in_cold_plate = workflow.add_task(
ActionTask(
...
inputs=Inputs(temperature=ParameterReference(parameter_id="cold_plate_temperature")),
)
)
Setting Parameters
Parameters are set in the publish stage of workflow execution. Parameters can be set in two ways:
As a response to CLI prompts.
By providing a parameters.json configuration file.
Setting parameters through CLI prompts
When publishing a workflow with parameters defined and no parameters file provided, parameters are set through prompts on the command line.
foo@bar:~$ linq workcell publish <workflow-id>
Enter Float value for parameter 'Cold Plate Temperature' or hit enter to use default value '10.0':
Once all parameters are provided the publish command will execute.
Setting parameters through a parameters file
Alternatively, rather than manually entering every parameter value through prompts on the command line, a JSON file specifying parameter values can be provided as an argument to the publish command.
linq workcell publish <workflow-id> --parameters <path_to_parameters_json>
Example parameters JSON:
{
"Cold Plate Temperature": 10.0,
"Scan Barcode": true,
"Method File Path": "path/to/method_file.txt"
}
Note
The parameters JSON schema is {<Type>ParameterDefinition.name
: value}.
Parameter Types
- class linq.parameters.BooleanParameterDefinition(*, id: str = ..., name: str = ..., always_required: bool = False, default: bool | None = ...)
- class linq.parameters.FloatParameterDefinition(*, id: str = ..., name: str = ..., always_required: bool = False, default: float | None = None, minimum: float | None = None, maximum: float | None = None)
- class linq.parameters.IntegerParameterDefinition(*, id: str = ..., name: str = ..., always_required: bool = False, default: int | None = None, minimum: int | None = None, maximum: int | None = None, multiple_of: int | None = None)
- class linq.parameters.StringParameterDefinition(*, id: str = ..., name: str = ..., always_required: bool = False, default: str | None = None, is_file_path: bool | None = False, is_directory_path: bool = False)