Flows
lume_services.flows.flow
Classes
MappedParameter
Bases: BaseModel
There are three types of mapped parameters: file, db, and raw.
file: File parameters are file outputs that will be loaded in downstream flows.
Downstream loading must use the packaged load_file
task in
lume_services.tasks.file
.
db: Database results ...
raw: Raw values are passed from task output to parameter input.
Attr
parent_flow_name (str): Parent flow holding origin of mapped parameter. parent_task_name (str): Task whose result is mapped to the parameter. map_type (Literal["file", "db", "raw"]): Type of mapping describing the parameters.
Attributes
parent_flow_name
class-attribute
parent_flow_name: str
parent_task_name
class-attribute
parent_task_name: str
map_type
class-attribute
map_type: Literal['file', 'db', 'raw'] = 'raw'
RawMappedParameter
Bases: MappedParameter
RawMappedParameters describe parameter mappings where the result of a task is used as the input to a parameter.
Attr
parent_flow_name (str): Parent flow holding origin of mapped parameter. parent_task_name (str): Task whose result is mapped to the parameter. map_type (Literal["file", "db", "raw"] = "raw"): The "raw" map type describes the one-to-one result to parameter map.
Attributes
map_type
class-attribute
map_type: str = Field('raw', const=True)
FileMappedParameter
Bases: MappedParameter
FileMappedParameters describe files passed between different flows. Files are saved as json representations describing file type (and serialization) and filesystem information.
Attr
parent_flow_name (str): Parent flow holding origin of mapped parameter. parent_task_name (str): Task whose result is mapped to the parameter. map_type (Literal["file", "db", "raw"] = "file"): The "file" map type describes the
Attributes
map_type
class-attribute
map_type: str = Field('file', const=True)
DBMappedParameter
Bases: MappedParameter
Attributes
map_type
class-attribute
map_type: str = Field('db', const=True)
attribute
class-attribute
attribute: str
attribute_index
class-attribute
attribute_index: Optional[List[str]]
Flow
Bases: BaseModel
Interface to a workflow object.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of flow |
flow_id |
Optional[str]
|
ID of flow as registered with Prefect. If running locally, this will be null. |
project_name |
Optional[str]
|
Name of Prefect project with which the flow is registered. If running locally this will be null. |
parameters |
Optional[Dict[str, Parameter]]
|
Dictionary of Prefect parameters associated with the flow. |
mapped_parameters |
Optional[Dict[str, MappedParameter]]
|
Parameters to be collected from results of other flows. |
task_slugs |
Optional[Dict[str, str]]
|
Slug of tasks associated with the Prefect flow. |
labels |
List[str] = ["lume-services"]
|
List of labels to assign to flow when registering with Prefect backend. This label is used to assign agents that will manage deployment. |
image |
str
|
Image inside which to run flow if deploying to remote backend. |
Attributes
name
class-attribute
name: str
flow_id
class-attribute
flow_id: Optional[str]
project_name
class-attribute
project_name: Optional[str]
prefect_flow
class-attribute
prefect_flow: Optional[PrefectFlow]
parameters
class-attribute
parameters: Optional[Dict[str, Parameter]]
mapped_parameters
class-attribute
mapped_parameters: Optional[Dict[str, MappedParameter]]
task_slugs
class-attribute
task_slugs: Optional[Dict[str, str]]
labels
class-attribute
labels: List[str] = ['lume-services']
image
class-attribute
image: str = 'build-test:latest'
Classes
Config
class-attribute
arbitrary_types_allowed = True
class-attribute
validate_assignment = True
Functions
validate_mapped_parameters
validate_mapped_parameters(v)
Source code in lume_services/flows/flow.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
load_flow
load_flow(
scheduling_service: SchedulingService = Provide[
Context.scheduling_service
],
) -> None
Loads Prefect flow artifact from the backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scheduling_service |
SchedulingService
|
Scheduling service. If not provided, uses injected service. |
Provide[Context.scheduling_service]
|
Source code in lume_services/flows/flow.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
|
register
register(
scheduling_service: SchedulingService = Provide[
Context.scheduling_service
],
) -> str
Register flow with SchedulingService backend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scheduling_service |
SchedulingService
|
Scheduling service. If not provided, uses injected service. |
Provide[Context.scheduling_service]
|
Returns:
Name | Type | Description |
---|---|---|
flow_id |
str
|
ID of registered flow. |
Source code in lume_services/flows/flow.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
run
run(
parameters,
run_config,
scheduling_service: SchedulingService = Provide[
Context.scheduling_service
],
)
Run the flow.
Source code in lume_services/flows/flow.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
|
run_and_return
run_and_return(
parameters,
run_config,
task_name: Optional[str],
scheduling_service: SchedulingService = Provide[
Context.scheduling_service
],
)
Run flow and return result. Result will reference either passed task name or the result of all tasks.
Source code in lume_services/flows/flow.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
|
FlowConfig
Bases: BaseModel
Attributes
image
class-attribute
image: Optional[str]
env
class-attribute
env: Optional[List[str]]
FlowRunConfig
Bases: BaseModel
Attributes
poll_interval
class-attribute
poll_interval: timedelta = timedelta(seconds=10)
scheduled_start_time
class-attribute
scheduled_start_time: Optional[datetime]
parameters
class-attribute
parameters: Optional[Dict[str, Any]]
run_config
class-attribute
run_config: Optional[RunConfig]
labels
class-attribute
labels: Optional[List[str]]
run_name
class-attribute
run_name: Optional[str]
Classes
Config
class-attribute
arbitrary_types_allowed = True
lume_services.flows.flow_of_flows
Classes
FlowOfFlows
Bases: Flow
Attributes
composing_flows
class-attribute
composing_flows: dict
Classes
Config
class-attribute
arbitrary_types_allowed = True
Functions
validate
validate(values: dict)
Validate composing flow data against Prefect server.
Source code in lume_services/flows/flow_of_flows.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
|
compose
compose(
image_name: str,
image_tag: str = "latest",
local: bool = False,
scheduling_service: SchedulingService = Provide[
Context.scheduling_service
],
) -> PrefectFlow
Compose Prefect flow from FlowOfFlows object. Uses base image assigned to the FlowOfFlows Object and builds a new Docker image containing the composite flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image_name |
str
|
Name of generated image. |
required |
image_tag |
str
|
Tag of generated image. |
'latest'
|
local |
bool=False
|
Whether to use local images for the base image. |
False
|
Returns:
Type | Description |
---|---|
PrefectFlow
|
PrefectFlow |
Source code in lume_services/flows/flow_of_flows.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
compose_and_register
compose_and_register()
Compose flow and register with project.
Returns:
Name | Type | Description |
---|---|---|
str | Registered flow id |
Source code in lume_services/flows/flow_of_flows.py
235 236 237 238 239 240 241 242 243 244 245 |
|
from_yaml
classmethod
from_yaml(
yaml_obj,
scheduling_service: SchedulingService = Provide[
Context.scheduling_service
],
)
Source code in lume_services/flows/flow_of_flows.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|