Parameter Types
The Latch SDK supports first-class static typing. All input parameters and output values must be annotated with types in the function signature. These type annotations validate task values and guide the construction of parameter-specific frontend components when your interface is generated at registration.
Supported Types
Below is an exhaustive list of workflow and task parameter types currently supported by the SDK, and how they translate to the workflow UI once the workflow is registered:
Integers
Boolean
Floats
Strings
Files
Directories
Enums
Note: As expressed in the Flyte Docs, Enum values can only be strings.
Unions
Along with the previous basic types, Union
and Optional
types from Python’s
typing
module give extra flexibility.
Recall that Optional[T] = Union[None, T]
.
Lists
Finally, we currently support a single collection type which is List[T]
, also
provided by the typing
module.
Dataclasses
Complex object types should be represented using a :class:~dataclasses.dataclass
. They render a group of input elements for each of the fields of the dataclass. These can be used in lists and maps, and are useful to model interdependent data, for example, pairs of reads or named samples.
Custom Types
If existing types are not sufficient to properly model the input or output data, it is possible to define your own custom types for use in tasks and workflows. Flyte documentation on custom type transformers describes this process. The workflow interface will show inputs for the underlying representation (the IDL) of the custom type.
Setting Default Values
If a parameter has a default value, it is displayed to the user in the frontend interface and passed to the workflow if the user does not change it. Default values are optional but encouraged as, if a reasonable default exists, it can improve the user experience by encouraging best practices and allowing users to focus on the settings that really matter to them.
Example
Here is the function header for Bactopia, a workflow available on Latch. To see how these inputs translate into a user interface, check out Bactopia on Latch.
Was this page helpful?