Flow
courseflow
has one Flow
class. Steps are added to particular
instances of Flow
s to construct different flows with different
functionalities.
- class flow.flow.Flow[RecordType]
An administrative flow that manages and runs different steps.
- __init__(name: str, description: str, record_storer_type: Type[RecordStorer[RecordType]], record_storer_name: str) None
Initialize the flow with a name, description, and a RecordStorer.
- Parameters:
name (str) – The name of the flow
description (str) – A high-level description of what the flow does
record_storer (RecordStorer[RecordType]) – The storage object used to access and store records
record_storer_name – The name of the record storer, to be used when configuring
- silent() None
Make the flow suppress terminal output.
- verbose() None
Enable terminal output, if it was previously disabled.
- logfile(file_path: str) None
Add a logfile path, to output logs to.
- Parameters:
file_path (str) – The path to log to
- Raises:
Exception – Raised if the file exists already and isn’t a file
- add_record_step(name: str, step: Type[FlowRecordStep[RecordType]]) None
Add a record step to the flow.
- Parameters:
name (str) – The name of the record step
step (Type[FlowRecordStep[RecordType]]) – The type of the record step to add
- Raises:
Exception – Raised if a step with the name already exists
- add_update_step(name: str, step: Type[FlowUpdateStep[RecordType]], depends_on: list[str] = []) None
Add an update step to the flow.
- Parameters:
name (str) – The name of the update step
step (Type[FlowUpdateStep[RecordType]]) – The type of the update step to add
depends_on (list[str]) – Names of others steps that this one should run after
- Raises:
Exception – Raised if a step with the name already exists, or if the step depends on other steps that don’t exist or are the wrong type
- add_propagate_step(name: str, step: Type[FlowPropagateStep[RecordType]], depends_on: list[str] = []) None
Add a propagate step to the flow.
- Parameters:
name (str) – The name of the propagate step
step (Type[FlowPropagateStep[RecordType]]) – The type of the propagate step to add
depends_on (list[str]) – Names of others steps that this one should run after
- Raises:
Exception – Raised if a step with the name already exists, or if the step depends on other steps that don’t exist or are the wrong type
- describe_config() dict[str, str | dict[str, str]]
Provide a dictionary describing the flow and all steps.
- Returns:
A mapping of configurations to descriptions, such that they could be taken in as a YAML file if used with the indicated types.
- Return type:
dict[str, str | dict[str, str]]
- config(config_dict: dict[str, Any]) None
Configure the flow and its steps.
- Parameters:
config_dict (dict[str, Any]) – The configurations for the flow
- Raises:
Exception – Raised if the configurations are incorrect. This can be called for a variety of reasons; the exception message will describe why
- run() None
Run the flow, running all of the associated steps.
- This will:
Get a list of records using the flow’s record storer
Run the flow’s record steps sequentially to add to the list of records
Run the flow’s update steps in parallel to update the list of records
Run the flow’s propagate steps in parallel to propagate the data in the list of records
Store the updated records using the flow’s record storer