omnipy.compute.flow
Flow definitions for composing tasks and subflows.
This module exposes Omnipy's public flow types. Use LinearFlowTemplate for
sequential pipelines, DagFlowTemplate for dependency-driven directed
acyclic graphs, and FuncFlowTemplate for flows expressed as a single
coordinating callable.
| ATTRIBUTE | DESCRIPTION |
|---|---|
LinearFlowTemplate |
Decorator-style template factory for sequential flows.
TYPE:
|
DagFlowTemplate |
Decorator-style template factory for directed acyclic graph flows.
TYPE:
|
FuncFlowTemplate |
Decorator-style template factory for callable-backed coordinating flows.
TYPE:
|
| CLASS | DESCRIPTION |
|---|---|
DagFlow |
Execute a flow whose child jobs exchange data through named DAG keys. |
DagFlowTemplateCore |
|
FlowBase |
Provide a shared marker base for Omnipy flow objects. |
FuncFlow |
Execute a flow backed by one coordinating callable. |
FuncFlowTemplateCore |
Implement the core template behavior for function flows. |
LinearFlow |
Execute a flow whose tasks run in declaration order. |
LinearFlowTemplateCore |
Implement the core template behavior for linear flows. |
| FUNCTION | DESCRIPTION |
|---|---|
DagFlowTemplate |
Decorator-style factory for defining directed acyclic graph flows. |
FuncFlowTemplate |
Decorator-style factory for defining callable-backed coordinating flows. |
LinearFlowTemplate |
Decorator-style factory for defining sequential flows. |
DagFlow
Bases: JobMixin[IsDagFlowTemplate[_CallP, _RetT], IsDagFlow[_CallP, _RetT], _CallP, _RetT], FlowBase, ChildJobListArgJobBase[IsDagFlowTemplate[_CallP, _RetT], IsDagFlow[_CallP, _RetT], _CallP, _RetT], Generic[_CallP, _RetT]
flowchart BT
omnipy.compute.flow.DagFlow[DagFlow]
omnipy.compute._job.JobMixin[JobMixin]
omnipy.compute.flow.FlowBase[FlowBase]
omnipy.compute._joblist_job.ChildJobListArgJobBase[ChildJobListArgJobBase]
omnipy.compute._func_job.FuncArgJobBase[FuncArgJobBase]
omnipy.compute._func_job.PlainFuncArgJobBase[PlainFuncArgJobBase]
omnipy.compute._job.JobBase[JobBase]
omnipy.hub.log.mixin.LogMixin[LogMixin]
omnipy.util.mixin.DynamicMixinAcceptor[DynamicMixinAcceptor]
omnipy.compute._job.JobMixin --> omnipy.compute.flow.DagFlow
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobMixin
omnipy.compute.flow.FlowBase --> omnipy.compute.flow.DagFlow
omnipy.compute._joblist_job.ChildJobListArgJobBase --> omnipy.compute.flow.DagFlow
omnipy.compute._func_job.FuncArgJobBase --> omnipy.compute._joblist_job.ChildJobListArgJobBase
omnipy.compute._func_job.PlainFuncArgJobBase --> omnipy.compute._func_job.FuncArgJobBase
omnipy.compute._job.JobBase --> omnipy.compute._func_job.PlainFuncArgJobBase
omnipy.hub.log.mixin.LogMixin --> omnipy.compute._job.JobBase
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobBase
click omnipy.compute.flow.DagFlow href "" "omnipy.compute.flow.DagFlow"
click omnipy.compute._job.JobMixin href "" "omnipy.compute._job.JobMixin"
click omnipy.compute.flow.FlowBase href "" "omnipy.compute.flow.FlowBase"
click omnipy.compute._joblist_job.ChildJobListArgJobBase href "" "omnipy.compute._joblist_job.ChildJobListArgJobBase"
click omnipy.compute._func_job.FuncArgJobBase href "" "omnipy.compute._func_job.FuncArgJobBase"
click omnipy.compute._func_job.PlainFuncArgJobBase href "" "omnipy.compute._func_job.PlainFuncArgJobBase"
click omnipy.compute._job.JobBase href "" "omnipy.compute._job.JobBase"
click omnipy.hub.log.mixin.LogMixin href "" "omnipy.hub.log.mixin.LogMixin"
click omnipy.util.mixin.DynamicMixinAcceptor href "" "omnipy.util.mixin.DynamicMixinAcceptor"
Execute a flow whose child jobs exchange data through named DAG keys.
A DagFlow routes values between child jobs by accumulated keyword name
rather than by one strict positional chain. Use it for branching and
joining pipelines whose dependencies form a directed acyclic graph.
Instances are typically produced by calling a DagFlowTemplate rather
than by constructing DagFlow directly.
| CLASS | DESCRIPTION |
|---|---|
DataClassAndJobParentInfo |
|
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
accept_mixin |
Register a mixin class for dynamic composition. |
create_job |
Create an applied job instance from the concrete job class. |
log |
Emit a log message, optionally using an explicit event timestamp. |
reset_mixins |
Clear all accepted mixins and restore the original init signature. |
revise |
Return a template reconstructed from this applied job. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
callable_type |
TYPE:
|
child_job_templates |
TYPE:
|
config |
Return the job configuration visible to this instance.
TYPE:
|
engine |
Return the engine associated with this job, if any.
TYPE:
|
in_flow_context |
Return whether the job is currently executing inside a flow context.
TYPE:
|
logger |
Return the logger bound to the concrete instance type.
TYPE:
|
time_of_cur_toplevel_flow_run |
Return the start time of the active top-level flow run, if any.
TYPE:
|
Source code in src/omnipy/compute/flow.py
config
property
config: IsJobConfig
Return the job configuration visible to this instance.
| RETURNS | DESCRIPTION |
|---|---|
IsJobConfig
|
Active job configuration used for runtime behavior.
TYPE:
|
engine
property
engine: IsEngine | None
Return the engine associated with this job, if any.
| RETURNS | DESCRIPTION |
|---|---|
IsEngine | None
|
IsEngine | None: Engine used for decoration and execution, or |
in_flow_context
property
Return whether the job is currently executing inside a flow context.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
logger
property
Return the logger bound to the concrete instance type.
| RETURNS | DESCRIPTION |
|---|---|
Logger
|
Logger used by the object for Omnipy log messages.
TYPE:
|
time_of_cur_toplevel_flow_run
property
Return the start time of the active top-level flow run, if any.
| RETURNS | DESCRIPTION |
|---|---|
datetime | None
|
datetime | None: Timestamp for the current outermost flow run, or |
DataClassAndJobParentInfo
Bases: NamedTuple
flowchart BT
omnipy.compute.flow.DagFlow.DataClassAndJobParentInfo[DataClassAndJobParentInfo]
click omnipy.compute.flow.DagFlow.DataClassAndJobParentInfo href "" "omnipy.compute.flow.DagFlow.DataClassAndJobParentInfo"
| ATTRIBUTE | DESCRIPTION |
|---|---|
dataset_or_model |
TYPE:
|
parent_coerces_from_kwargs |
TYPE:
|
Source code in src/omnipy/compute/_joblist_job.py
__init__
accept_mixin
classmethod
Register a mixin class for dynamic composition.
| PARAMETER | DESCRIPTION |
|---|---|
mixin_cls
|
Mixin class whose
TYPE:
|
Source code in src/omnipy/util/mixin.py
create_job
classmethod
Create an applied job instance from the concrete job class.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional constructor arguments.
TYPE:
|
**kwargs
|
Keyword constructor arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_JobT
|
New applied job instance.
TYPE:
|
Source code in src/omnipy/compute/_job.py
log
Emit a log message, optionally using an explicit event timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
log_msg
|
Message text to send to the logger.
TYPE:
|
level
|
Standard library logging level.
TYPE:
|
datetime_obj
|
Timestamp to attach to the record instead of wall-clock time.
TYPE:
|
Source code in src/omnipy/hub/log/mixin.py
reset_mixins
classmethod
Clear all accepted mixins and restore the original init signature.
revise
Return a template reconstructed from this applied job.
| RETURNS | DESCRIPTION |
|---|---|
_JobTemplateT
|
Template carrying the current job configuration.
TYPE:
|
Source code in src/omnipy/compute/_job.py
DagFlowTemplateCore
Bases: ChildJobListArgJobBase[IsDagFlowTemplate[_CallP, _RetT], IsDagFlow[_CallP, _RetT], _CallP, _RetT], JobTemplateMixin[IsDagFlowTemplate[_CallP, _RetT], IsDagFlow[_CallP, _RetT], _CallP, _RetT], FlowBase, Generic[_CallP, _RetT]
flowchart BT
omnipy.compute.flow.DagFlowTemplateCore[DagFlowTemplateCore]
omnipy.compute._joblist_job.ChildJobListArgJobBase[ChildJobListArgJobBase]
omnipy.compute._func_job.FuncArgJobBase[FuncArgJobBase]
omnipy.compute._func_job.PlainFuncArgJobBase[PlainFuncArgJobBase]
omnipy.compute._job.JobBase[JobBase]
omnipy.hub.log.mixin.LogMixin[LogMixin]
omnipy.util.mixin.DynamicMixinAcceptor[DynamicMixinAcceptor]
omnipy.compute._job.JobTemplateMixin[JobTemplateMixin]
omnipy.compute.flow.FlowBase[FlowBase]
omnipy.compute._joblist_job.ChildJobListArgJobBase --> omnipy.compute.flow.DagFlowTemplateCore
omnipy.compute._func_job.FuncArgJobBase --> omnipy.compute._joblist_job.ChildJobListArgJobBase
omnipy.compute._func_job.PlainFuncArgJobBase --> omnipy.compute._func_job.FuncArgJobBase
omnipy.compute._job.JobBase --> omnipy.compute._func_job.PlainFuncArgJobBase
omnipy.hub.log.mixin.LogMixin --> omnipy.compute._job.JobBase
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobBase
omnipy.compute._job.JobTemplateMixin --> omnipy.compute.flow.DagFlowTemplateCore
omnipy.compute.flow.FlowBase --> omnipy.compute.flow.DagFlowTemplateCore
click omnipy.compute.flow.DagFlowTemplateCore href "" "omnipy.compute.flow.DagFlowTemplateCore"
click omnipy.compute._joblist_job.ChildJobListArgJobBase href "" "omnipy.compute._joblist_job.ChildJobListArgJobBase"
click omnipy.compute._func_job.FuncArgJobBase href "" "omnipy.compute._func_job.FuncArgJobBase"
click omnipy.compute._func_job.PlainFuncArgJobBase href "" "omnipy.compute._func_job.PlainFuncArgJobBase"
click omnipy.compute._job.JobBase href "" "omnipy.compute._job.JobBase"
click omnipy.hub.log.mixin.LogMixin href "" "omnipy.hub.log.mixin.LogMixin"
click omnipy.util.mixin.DynamicMixinAcceptor href "" "omnipy.util.mixin.DynamicMixinAcceptor"
click omnipy.compute._job.JobTemplateMixin href "" "omnipy.compute._job.JobTemplateMixin"
click omnipy.compute.flow.FlowBase href "" "omnipy.compute.flow.FlowBase"
| CLASS | DESCRIPTION |
|---|---|
DataClassAndJobParentInfo |
|
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
accept_mixin |
Register a mixin class for dynamic composition. |
apply |
Create an applied job from this template without executing it. |
create_job_template |
Create a job template instance from the concrete template class. |
log |
Emit a log message, optionally using an explicit event timestamp. |
refine |
Forward refinement to the shared template lifecycle implementation. |
reset_mixins |
Clear all accepted mixins and restore the original init signature. |
run |
Apply the template and execute the resulting job immediately. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
callable_type |
TYPE:
|
child_job_templates |
TYPE:
|
config |
Return the job configuration visible to this instance.
TYPE:
|
engine |
Return the engine associated with this job, if any.
TYPE:
|
in_flow_context |
Return whether the job is currently executing inside a flow context.
TYPE:
|
logger |
Return the logger bound to the concrete instance type.
TYPE:
|
Source code in src/omnipy/compute/flow.py
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 | |
config
property
config: IsJobConfig
Return the job configuration visible to this instance.
| RETURNS | DESCRIPTION |
|---|---|
IsJobConfig
|
Active job configuration used for runtime behavior.
TYPE:
|
engine
property
engine: IsEngine | None
Return the engine associated with this job, if any.
| RETURNS | DESCRIPTION |
|---|---|
IsEngine | None
|
IsEngine | None: Engine used for decoration and execution, or |
in_flow_context
property
Return whether the job is currently executing inside a flow context.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
logger
property
Return the logger bound to the concrete instance type.
| RETURNS | DESCRIPTION |
|---|---|
Logger
|
Logger used by the object for Omnipy log messages.
TYPE:
|
DataClassAndJobParentInfo
Bases: NamedTuple
flowchart BT
omnipy.compute.flow.DagFlowTemplateCore.DataClassAndJobParentInfo[DataClassAndJobParentInfo]
click omnipy.compute.flow.DagFlowTemplateCore.DataClassAndJobParentInfo href "" "omnipy.compute.flow.DagFlowTemplateCore.DataClassAndJobParentInfo"
| ATTRIBUTE | DESCRIPTION |
|---|---|
dataset_or_model |
TYPE:
|
parent_coerces_from_kwargs |
TYPE:
|
Source code in src/omnipy/compute/_joblist_job.py
__init__
__init__(
job_func: Callable[_CallP, _RetT],
/,
*child_job_templates: ChildJobTemplateLike,
**kwargs: object,
) -> None
Source code in src/omnipy/compute/_joblist_job.py
accept_mixin
classmethod
Register a mixin class for dynamic composition.
| PARAMETER | DESCRIPTION |
|---|---|
mixin_cls
|
Mixin class whose
TYPE:
|
Source code in src/omnipy/util/mixin.py
apply
Create an applied job from this template without executing it.
| RETURNS | DESCRIPTION |
|---|---|
_JobT
|
Applied job instance ready to be called.
TYPE:
|
Source code in src/omnipy/compute/_job.py
create_job_template
classmethod
Create a job template instance from the concrete template class.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional constructor arguments.
TYPE:
|
**kwargs
|
Keyword constructor arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_JobTemplateT
|
New job template instance.
TYPE:
|
Source code in src/omnipy/compute/_job.py
log
Emit a log message, optionally using an explicit event timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
log_msg
|
Message text to send to the logger.
TYPE:
|
level
|
Standard library logging level.
TYPE:
|
datetime_obj
|
Timestamp to attach to the record instead of wall-clock time.
TYPE:
|
Source code in src/omnipy/hub/log/mixin.py
refine
Forward refinement to the shared template lifecycle implementation.
See IsFuncArgJobTemplate.refine and
IsChildJobListArgJobTemplate.refine.
Source code in src/omnipy/compute/_job.py
reset_mixins
classmethod
Clear all accepted mixins and restore the original init signature.
run
Apply the template and execute the resulting job immediately.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional arguments passed to the applied job.
TYPE:
|
**kwargs
|
Keyword arguments passed to the applied job.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_RetCovT
|
Result returned by the applied job.
TYPE:
|
Source code in src/omnipy/compute/_job.py
FlowBase
Provide a shared marker base for Omnipy flow objects.
FlowBase exists to give concrete flow templates and executable flow
instances a common nominal base type. It does not define behavior on its
own, but it makes flow-specific mixin registration and type-based checks
possible within the compute subsystem.
- Reference Code reference
Source code in src/omnipy/compute/flow.py
FuncFlow
Bases: JobMixin[IsFuncFlowTemplate[_CallP, _RetT], IsFuncFlow[_CallP, _RetT], _CallP, _RetT], FlowBase, FuncArgJobBase[IsFuncFlowTemplate[_CallP, _RetT], IsFuncFlow[_CallP, _RetT], _CallP, _RetT], Generic[_CallP, _RetT]
flowchart BT
omnipy.compute.flow.FuncFlow[FuncFlow]
omnipy.compute._job.JobMixin[JobMixin]
omnipy.compute.flow.FlowBase[FlowBase]
omnipy.compute._func_job.FuncArgJobBase[FuncArgJobBase]
omnipy.compute._func_job.PlainFuncArgJobBase[PlainFuncArgJobBase]
omnipy.compute._job.JobBase[JobBase]
omnipy.hub.log.mixin.LogMixin[LogMixin]
omnipy.util.mixin.DynamicMixinAcceptor[DynamicMixinAcceptor]
omnipy.compute._job.JobMixin --> omnipy.compute.flow.FuncFlow
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobMixin
omnipy.compute.flow.FlowBase --> omnipy.compute.flow.FuncFlow
omnipy.compute._func_job.FuncArgJobBase --> omnipy.compute.flow.FuncFlow
omnipy.compute._func_job.PlainFuncArgJobBase --> omnipy.compute._func_job.FuncArgJobBase
omnipy.compute._job.JobBase --> omnipy.compute._func_job.PlainFuncArgJobBase
omnipy.hub.log.mixin.LogMixin --> omnipy.compute._job.JobBase
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobBase
click omnipy.compute.flow.FuncFlow href "" "omnipy.compute.flow.FuncFlow"
click omnipy.compute._job.JobMixin href "" "omnipy.compute._job.JobMixin"
click omnipy.compute.flow.FlowBase href "" "omnipy.compute.flow.FlowBase"
click omnipy.compute._func_job.FuncArgJobBase href "" "omnipy.compute._func_job.FuncArgJobBase"
click omnipy.compute._func_job.PlainFuncArgJobBase href "" "omnipy.compute._func_job.PlainFuncArgJobBase"
click omnipy.compute._job.JobBase href "" "omnipy.compute._job.JobBase"
click omnipy.hub.log.mixin.LogMixin href "" "omnipy.hub.log.mixin.LogMixin"
click omnipy.util.mixin.DynamicMixinAcceptor href "" "omnipy.util.mixin.DynamicMixinAcceptor"
Execute a flow backed by one coordinating callable.
A FuncFlow runs the wrapped callable itself as the flow body instead of
orchestrating an explicit child-job list. Use it when one callable already
captures the desired control flow and runtime behavior.
Instances are typically produced by calling a FuncFlowTemplate rather
than by constructing FuncFlow directly.
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
accept_mixin |
Register a mixin class for dynamic composition. |
create_job |
Create an applied job instance from the concrete job class. |
log |
Emit a log message, optionally using an explicit event timestamp. |
reset_mixins |
Clear all accepted mixins and restore the original init signature. |
revise |
Return a template reconstructed from this applied job. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
callable_type |
TYPE:
|
config |
Return the job configuration visible to this instance.
TYPE:
|
engine |
Return the engine associated with this job, if any.
TYPE:
|
in_flow_context |
Return whether the job is currently executing inside a flow context.
TYPE:
|
logger |
Return the logger bound to the concrete instance type.
TYPE:
|
time_of_cur_toplevel_flow_run |
Return the start time of the active top-level flow run, if any.
TYPE:
|
Source code in src/omnipy/compute/flow.py
config
property
config: IsJobConfig
Return the job configuration visible to this instance.
| RETURNS | DESCRIPTION |
|---|---|
IsJobConfig
|
Active job configuration used for runtime behavior.
TYPE:
|
engine
property
engine: IsEngine | None
Return the engine associated with this job, if any.
| RETURNS | DESCRIPTION |
|---|---|
IsEngine | None
|
IsEngine | None: Engine used for decoration and execution, or |
in_flow_context
property
Return whether the job is currently executing inside a flow context.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
logger
property
Return the logger bound to the concrete instance type.
| RETURNS | DESCRIPTION |
|---|---|
Logger
|
Logger used by the object for Omnipy log messages.
TYPE:
|
time_of_cur_toplevel_flow_run
property
Return the start time of the active top-level flow run, if any.
| RETURNS | DESCRIPTION |
|---|---|
datetime | None
|
datetime | None: Timestamp for the current outermost flow run, or |
__init__
accept_mixin
classmethod
Register a mixin class for dynamic composition.
| PARAMETER | DESCRIPTION |
|---|---|
mixin_cls
|
Mixin class whose
TYPE:
|
Source code in src/omnipy/util/mixin.py
create_job
classmethod
Create an applied job instance from the concrete job class.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional constructor arguments.
TYPE:
|
**kwargs
|
Keyword constructor arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_JobT
|
New applied job instance.
TYPE:
|
Source code in src/omnipy/compute/_job.py
log
Emit a log message, optionally using an explicit event timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
log_msg
|
Message text to send to the logger.
TYPE:
|
level
|
Standard library logging level.
TYPE:
|
datetime_obj
|
Timestamp to attach to the record instead of wall-clock time.
TYPE:
|
Source code in src/omnipy/hub/log/mixin.py
reset_mixins
classmethod
Clear all accepted mixins and restore the original init signature.
revise
Return a template reconstructed from this applied job.
| RETURNS | DESCRIPTION |
|---|---|
_JobTemplateT
|
Template carrying the current job configuration.
TYPE:
|
Source code in src/omnipy/compute/_job.py
FuncFlowTemplateCore
Bases: FuncArgJobBase[IsFuncFlowTemplate[_CallP, _RetT], IsFuncFlow[_CallP, _RetT], _CallP, _RetT], JobTemplateMixin[IsFuncFlowTemplate[_CallP, _RetT], IsFuncFlow[_CallP, _RetT], _CallP, _RetT], FlowBase, Generic[_CallP, _RetT]
flowchart BT
omnipy.compute.flow.FuncFlowTemplateCore[FuncFlowTemplateCore]
omnipy.compute._func_job.FuncArgJobBase[FuncArgJobBase]
omnipy.compute._func_job.PlainFuncArgJobBase[PlainFuncArgJobBase]
omnipy.compute._job.JobBase[JobBase]
omnipy.hub.log.mixin.LogMixin[LogMixin]
omnipy.util.mixin.DynamicMixinAcceptor[DynamicMixinAcceptor]
omnipy.compute._job.JobTemplateMixin[JobTemplateMixin]
omnipy.compute.flow.FlowBase[FlowBase]
omnipy.compute._func_job.FuncArgJobBase --> omnipy.compute.flow.FuncFlowTemplateCore
omnipy.compute._func_job.PlainFuncArgJobBase --> omnipy.compute._func_job.FuncArgJobBase
omnipy.compute._job.JobBase --> omnipy.compute._func_job.PlainFuncArgJobBase
omnipy.hub.log.mixin.LogMixin --> omnipy.compute._job.JobBase
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobBase
omnipy.compute._job.JobTemplateMixin --> omnipy.compute.flow.FuncFlowTemplateCore
omnipy.compute.flow.FlowBase --> omnipy.compute.flow.FuncFlowTemplateCore
click omnipy.compute.flow.FuncFlowTemplateCore href "" "omnipy.compute.flow.FuncFlowTemplateCore"
click omnipy.compute._func_job.FuncArgJobBase href "" "omnipy.compute._func_job.FuncArgJobBase"
click omnipy.compute._func_job.PlainFuncArgJobBase href "" "omnipy.compute._func_job.PlainFuncArgJobBase"
click omnipy.compute._job.JobBase href "" "omnipy.compute._job.JobBase"
click omnipy.hub.log.mixin.LogMixin href "" "omnipy.hub.log.mixin.LogMixin"
click omnipy.util.mixin.DynamicMixinAcceptor href "" "omnipy.util.mixin.DynamicMixinAcceptor"
click omnipy.compute._job.JobTemplateMixin href "" "omnipy.compute._job.JobTemplateMixin"
click omnipy.compute.flow.FlowBase href "" "omnipy.compute.flow.FlowBase"
Implement the core template behavior for function flows.
A function flow template wraps a Python callable that orchestrates work as a flow. Use this when the control flow is easiest to express directly in Python instead of as an explicit task list or dependency graph.
Decorator usage
Apply the template factory as a decorator to a Python callable. The wrapped callable becomes a reusable job template whose public outer signature is visible to template users and to the applied jobs created from it.
Wrapped callable
The wrapped callable defines both the implementation and the public outer signature of the flow.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.FuncFlowTemplate()
... def append_suffix_to_all(
... dataset: TextDataset,
... suffix: str,
... ) -> TextDataset:
... output_dataset = TextDataset()
... for title, data_file in dataset.items():
... output_dataset[title] = f'{data_file.content}{suffix}'
... return output_dataset
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> append_suffix_to_all.run(text_files, '!') == expected
True
Outer signature and modifiers
The wrapped callable's parameter list and return annotation define the outer interface of the template.
fixed_params permanently supplies selected callable parameters.
param_key_map renames selected callable parameters to external
keyword names that callers or parent flows use when supplying inputs.
iterate_over_data_files, output_dataset_param, and
output_dataset_cls adapt that outer interface for dataset-wise
iteration.
When iterate_over_data_files=True and the inner first parameter is
annotated as Model[T], callers see an outer
dataset: Dataset[Model[T]] parameter and the outer return type
becomes a dataset of the per-item return type. The inner callable still
receives one model object at a time.
result_key wraps the returned value in a single-key dictionary,
which is especially useful when a downstream DAG step should receive
the result under a predictable name.
Examples:
>>> # With modifiers
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_other(number: int, other: int) -> int:
... return number + other
>>> plus_one = plus_other.refine(fixed_params={'other': 1})
>>> plus_one.run(4)
5
>>> plus_x = plus_other.refine(param_key_map={'other': 'x'})
>>> plus_x.run(4, x=3)
7
>>> plus_one_dict = plus_one.refine(result_key='number')
>>> plus_one_dict.run(4)
{'number': 5}
Examples:
>>> # With dataset-wise iteration
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def add_suffix(
... data_file: TextModel,
... suffix: str,
... ) -> TextModel:
... return f'{data_file.content}{suffix}'
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> add_suffix.run(text_files, suffix='!') == expected
True
Tasks and flows
Tasks are terminal jobs: they wrap one callable and execute one compute step.
Flows are orchestration jobs: they may contain child tasks and child flows, so larger pipelines can be assembled hierarchically from smaller reusable pieces.
Lifecycle
Apply a template with apply()
to create a runnable job with engine decorators and current config attached.
Call the resulting applied job with runtime arguments.
Use run() as a shorthand for
apply() followed immediately by calling the applied job.
Use refine() to reuse a
template while changing configuration such as name, fixed_params,
or param_key_map.
Use revise() on an applied job to
reconstruct a template from that job's current configuration.
Examples:
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_one(number: int) -> int:
... return number + 1
>>> plus_one.run(1)
2
>>> applied_job = plus_one.apply()
>>> applied_job(2)
3
>>> refined_template = plus_one.refine(name='plus_one_renamed')
>>> revised_template = applied_job.revise()
Instances are normally produced through the FuncFlowTemplate decorator factory rather than by direct construction.
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
accept_mixin |
Register a mixin class for dynamic composition. |
apply |
Create an applied job from this template without executing it. |
create_job_template |
Create a job template instance from the concrete template class. |
log |
Emit a log message, optionally using an explicit event timestamp. |
refine |
Forward refinement to the shared template lifecycle implementation. |
reset_mixins |
Clear all accepted mixins and restore the original init signature. |
run |
Apply the template and execute the resulting job immediately. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
callable_type |
TYPE:
|
config |
Return the job configuration visible to this instance.
TYPE:
|
engine |
Return the engine associated with this job, if any.
TYPE:
|
in_flow_context |
Return whether the job is currently executing inside a flow context.
TYPE:
|
logger |
Return the logger bound to the concrete instance type.
TYPE:
|
Source code in src/omnipy/compute/flow.py
1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 | |
config
property
config: IsJobConfig
Return the job configuration visible to this instance.
| RETURNS | DESCRIPTION |
|---|---|
IsJobConfig
|
Active job configuration used for runtime behavior.
TYPE:
|
engine
property
engine: IsEngine | None
Return the engine associated with this job, if any.
| RETURNS | DESCRIPTION |
|---|---|
IsEngine | None
|
IsEngine | None: Engine used for decoration and execution, or |
in_flow_context
property
Return whether the job is currently executing inside a flow context.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
logger
property
Return the logger bound to the concrete instance type.
| RETURNS | DESCRIPTION |
|---|---|
Logger
|
Logger used by the object for Omnipy log messages.
TYPE:
|
__init__
accept_mixin
classmethod
Register a mixin class for dynamic composition.
| PARAMETER | DESCRIPTION |
|---|---|
mixin_cls
|
Mixin class whose
TYPE:
|
Source code in src/omnipy/util/mixin.py
apply
Create an applied job from this template without executing it.
| RETURNS | DESCRIPTION |
|---|---|
_JobT
|
Applied job instance ready to be called.
TYPE:
|
Source code in src/omnipy/compute/_job.py
create_job_template
classmethod
Create a job template instance from the concrete template class.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional constructor arguments.
TYPE:
|
**kwargs
|
Keyword constructor arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_JobTemplateT
|
New job template instance.
TYPE:
|
Source code in src/omnipy/compute/_job.py
log
Emit a log message, optionally using an explicit event timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
log_msg
|
Message text to send to the logger.
TYPE:
|
level
|
Standard library logging level.
TYPE:
|
datetime_obj
|
Timestamp to attach to the record instead of wall-clock time.
TYPE:
|
Source code in src/omnipy/hub/log/mixin.py
refine
Forward refinement to the shared template lifecycle implementation.
See IsFuncArgJobTemplate.refine and
IsChildJobListArgJobTemplate.refine.
Source code in src/omnipy/compute/_job.py
reset_mixins
classmethod
Clear all accepted mixins and restore the original init signature.
run
Apply the template and execute the resulting job immediately.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional arguments passed to the applied job.
TYPE:
|
**kwargs
|
Keyword arguments passed to the applied job.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_RetCovT
|
Result returned by the applied job.
TYPE:
|
Source code in src/omnipy/compute/_job.py
LinearFlow
Bases: JobMixin[IsLinearFlowTemplate[_CallP, _RetT], IsLinearFlow[_CallP, _RetT], _CallP, _RetT], FlowBase, ChildJobListArgJobBase[IsLinearFlowTemplate[_CallP, _RetT], IsLinearFlow[_CallP, _RetT], _CallP, _RetT], Generic[_CallP, _RetT]
flowchart BT
omnipy.compute.flow.LinearFlow[LinearFlow]
omnipy.compute._job.JobMixin[JobMixin]
omnipy.compute.flow.FlowBase[FlowBase]
omnipy.compute._joblist_job.ChildJobListArgJobBase[ChildJobListArgJobBase]
omnipy.compute._func_job.FuncArgJobBase[FuncArgJobBase]
omnipy.compute._func_job.PlainFuncArgJobBase[PlainFuncArgJobBase]
omnipy.compute._job.JobBase[JobBase]
omnipy.hub.log.mixin.LogMixin[LogMixin]
omnipy.util.mixin.DynamicMixinAcceptor[DynamicMixinAcceptor]
omnipy.compute._job.JobMixin --> omnipy.compute.flow.LinearFlow
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobMixin
omnipy.compute.flow.FlowBase --> omnipy.compute.flow.LinearFlow
omnipy.compute._joblist_job.ChildJobListArgJobBase --> omnipy.compute.flow.LinearFlow
omnipy.compute._func_job.FuncArgJobBase --> omnipy.compute._joblist_job.ChildJobListArgJobBase
omnipy.compute._func_job.PlainFuncArgJobBase --> omnipy.compute._func_job.FuncArgJobBase
omnipy.compute._job.JobBase --> omnipy.compute._func_job.PlainFuncArgJobBase
omnipy.hub.log.mixin.LogMixin --> omnipy.compute._job.JobBase
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobBase
click omnipy.compute.flow.LinearFlow href "" "omnipy.compute.flow.LinearFlow"
click omnipy.compute._job.JobMixin href "" "omnipy.compute._job.JobMixin"
click omnipy.compute.flow.FlowBase href "" "omnipy.compute.flow.FlowBase"
click omnipy.compute._joblist_job.ChildJobListArgJobBase href "" "omnipy.compute._joblist_job.ChildJobListArgJobBase"
click omnipy.compute._func_job.FuncArgJobBase href "" "omnipy.compute._func_job.FuncArgJobBase"
click omnipy.compute._func_job.PlainFuncArgJobBase href "" "omnipy.compute._func_job.PlainFuncArgJobBase"
click omnipy.compute._job.JobBase href "" "omnipy.compute._job.JobBase"
click omnipy.hub.log.mixin.LogMixin href "" "omnipy.hub.log.mixin.LogMixin"
click omnipy.util.mixin.DynamicMixinAcceptor href "" "omnipy.util.mixin.DynamicMixinAcceptor"
Execute a flow whose tasks run in declaration order.
A LinearFlow runs its constituent tasks in declaration order, making
each step wait for the previous one to finish. Use it for pipelines where
every stage depends on the output or side effects of the stage before it.
Instances are typically produced by calling a LinearFlowTemplate
rather than by constructing LinearFlow directly.
| CLASS | DESCRIPTION |
|---|---|
DataClassAndJobParentInfo |
|
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
accept_mixin |
Register a mixin class for dynamic composition. |
create_job |
Create an applied job instance from the concrete job class. |
log |
Emit a log message, optionally using an explicit event timestamp. |
reset_mixins |
Clear all accepted mixins and restore the original init signature. |
revise |
Return a template reconstructed from this applied job. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
callable_type |
TYPE:
|
child_job_templates |
TYPE:
|
config |
Return the job configuration visible to this instance.
TYPE:
|
engine |
Return the engine associated with this job, if any.
TYPE:
|
in_flow_context |
Return whether the job is currently executing inside a flow context.
TYPE:
|
logger |
Return the logger bound to the concrete instance type.
TYPE:
|
time_of_cur_toplevel_flow_run |
Return the start time of the active top-level flow run, if any.
TYPE:
|
Source code in src/omnipy/compute/flow.py
config
property
config: IsJobConfig
Return the job configuration visible to this instance.
| RETURNS | DESCRIPTION |
|---|---|
IsJobConfig
|
Active job configuration used for runtime behavior.
TYPE:
|
engine
property
engine: IsEngine | None
Return the engine associated with this job, if any.
| RETURNS | DESCRIPTION |
|---|---|
IsEngine | None
|
IsEngine | None: Engine used for decoration and execution, or |
in_flow_context
property
Return whether the job is currently executing inside a flow context.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
logger
property
Return the logger bound to the concrete instance type.
| RETURNS | DESCRIPTION |
|---|---|
Logger
|
Logger used by the object for Omnipy log messages.
TYPE:
|
time_of_cur_toplevel_flow_run
property
Return the start time of the active top-level flow run, if any.
| RETURNS | DESCRIPTION |
|---|---|
datetime | None
|
datetime | None: Timestamp for the current outermost flow run, or |
DataClassAndJobParentInfo
Bases: NamedTuple
flowchart BT
omnipy.compute.flow.LinearFlow.DataClassAndJobParentInfo[DataClassAndJobParentInfo]
click omnipy.compute.flow.LinearFlow.DataClassAndJobParentInfo href "" "omnipy.compute.flow.LinearFlow.DataClassAndJobParentInfo"
| ATTRIBUTE | DESCRIPTION |
|---|---|
dataset_or_model |
TYPE:
|
parent_coerces_from_kwargs |
TYPE:
|
Source code in src/omnipy/compute/_joblist_job.py
__init__
accept_mixin
classmethod
Register a mixin class for dynamic composition.
| PARAMETER | DESCRIPTION |
|---|---|
mixin_cls
|
Mixin class whose
TYPE:
|
Source code in src/omnipy/util/mixin.py
create_job
classmethod
Create an applied job instance from the concrete job class.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional constructor arguments.
TYPE:
|
**kwargs
|
Keyword constructor arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_JobT
|
New applied job instance.
TYPE:
|
Source code in src/omnipy/compute/_job.py
log
Emit a log message, optionally using an explicit event timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
log_msg
|
Message text to send to the logger.
TYPE:
|
level
|
Standard library logging level.
TYPE:
|
datetime_obj
|
Timestamp to attach to the record instead of wall-clock time.
TYPE:
|
Source code in src/omnipy/hub/log/mixin.py
reset_mixins
classmethod
Clear all accepted mixins and restore the original init signature.
revise
Return a template reconstructed from this applied job.
| RETURNS | DESCRIPTION |
|---|---|
_JobTemplateT
|
Template carrying the current job configuration.
TYPE:
|
Source code in src/omnipy/compute/_job.py
LinearFlowTemplateCore
Bases: ChildJobListArgJobBase[IsLinearFlowTemplate[_CallP, _RetT], IsLinearFlow[_CallP, _RetT], _CallP, _RetT], JobTemplateMixin[IsLinearFlowTemplate[_CallP, _RetT], IsLinearFlow[_CallP, _RetT], _CallP, _RetT], FlowBase, Generic[_CallP, _RetT]
flowchart BT
omnipy.compute.flow.LinearFlowTemplateCore[LinearFlowTemplateCore]
omnipy.compute._joblist_job.ChildJobListArgJobBase[ChildJobListArgJobBase]
omnipy.compute._func_job.FuncArgJobBase[FuncArgJobBase]
omnipy.compute._func_job.PlainFuncArgJobBase[PlainFuncArgJobBase]
omnipy.compute._job.JobBase[JobBase]
omnipy.hub.log.mixin.LogMixin[LogMixin]
omnipy.util.mixin.DynamicMixinAcceptor[DynamicMixinAcceptor]
omnipy.compute._job.JobTemplateMixin[JobTemplateMixin]
omnipy.compute.flow.FlowBase[FlowBase]
omnipy.compute._joblist_job.ChildJobListArgJobBase --> omnipy.compute.flow.LinearFlowTemplateCore
omnipy.compute._func_job.FuncArgJobBase --> omnipy.compute._joblist_job.ChildJobListArgJobBase
omnipy.compute._func_job.PlainFuncArgJobBase --> omnipy.compute._func_job.FuncArgJobBase
omnipy.compute._job.JobBase --> omnipy.compute._func_job.PlainFuncArgJobBase
omnipy.hub.log.mixin.LogMixin --> omnipy.compute._job.JobBase
omnipy.util.mixin.DynamicMixinAcceptor --> omnipy.compute._job.JobBase
omnipy.compute._job.JobTemplateMixin --> omnipy.compute.flow.LinearFlowTemplateCore
omnipy.compute.flow.FlowBase --> omnipy.compute.flow.LinearFlowTemplateCore
click omnipy.compute.flow.LinearFlowTemplateCore href "" "omnipy.compute.flow.LinearFlowTemplateCore"
click omnipy.compute._joblist_job.ChildJobListArgJobBase href "" "omnipy.compute._joblist_job.ChildJobListArgJobBase"
click omnipy.compute._func_job.FuncArgJobBase href "" "omnipy.compute._func_job.FuncArgJobBase"
click omnipy.compute._func_job.PlainFuncArgJobBase href "" "omnipy.compute._func_job.PlainFuncArgJobBase"
click omnipy.compute._job.JobBase href "" "omnipy.compute._job.JobBase"
click omnipy.hub.log.mixin.LogMixin href "" "omnipy.hub.log.mixin.LogMixin"
click omnipy.util.mixin.DynamicMixinAcceptor href "" "omnipy.util.mixin.DynamicMixinAcceptor"
click omnipy.compute._job.JobTemplateMixin href "" "omnipy.compute._job.JobTemplateMixin"
click omnipy.compute.flow.FlowBase href "" "omnipy.compute.flow.FlowBase"
Implement the core template behavior for linear flows.
A linear flow template wraps a Python callable together with an ordered list of child job templates that run sequentially. Use this when work should proceed step by step in a fixed declaration order.
Decorator usage
Apply the template factory as a decorator to a Python callable. The wrapped callable becomes a reusable job template whose public outer signature is visible to template users and to the applied jobs created from it.
Outer callable and child jobs
The wrapped callable defines the public outer signature of the flow, while the child-job list defines the executed body.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def normalize_text(data_file: TextModel) -> TextModel:
... return data_file.content.strip().lower()
>>> @om.LinearFlowTemplate(normalize_text)
... def clean_texts(
... dataset: TextDataset,
... ) -> TextDataset:
... return dataset
>>> text_files = TextDataset({'a': ' Hi ', 'b': 'BYE '})
>>> expected = TextDataset({'a': 'hi', 'b': 'bye'})
>>> clean_texts.run(text_files) == expected
True
Child jobs and data classes
Child-job templates may be TaskTemplate or flow-template instances. This lets flows nest other flows as well as terminal tasks.
In linear and DAG flows, Model and Dataset subclasses are also allowed as child-job entries. During apply, they are coerced into helper task templates that construct the requested data object from positional input in linear flows or from keyword-matched input in DAG flows.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.LinearFlowTemplate(TextModel)
... def wrap_text(raw_text: str) -> TextModel:
... return TextModel(raw_text)
>>> wrap_text.run('hello').content
'hello'
>>> @om.DagFlowTemplate(TextDataset)
... def collect_texts(first: str, second: str) -> TextDataset:
... return TextDataset({'first': first, 'second': second})
>>> collect_texts.run(first='hello', second='bye') == TextDataset({
... 'first': 'hello',
... 'second': 'bye',
... })
True
Callable-type validation
For linear and DAG flows, the outer callable is primarily declarative: its signature exposes the public flow interface, while child jobs define the executed body.
The outer callable type is validated against the child-job composition. The terminal child determines whether the flow behaves like a function or generator, and any async child lifts the full flow to an async callable type.
As a result, a sync-function outer callable fits sync child execution,
a generator outer callable fits generator-producing terminal children,
and async outer callables are required when child composition is async.
Mismatches raise TypeError when the flow template is created.
Generator shorthand with Void
When the validated outer callable must be a generator or async-generator only to expose the correct public signature, use Void in the body:
Examples:
>>> @om.LinearFlowTemplate(emit_lines)
... def line_stream() -> Iterator[str]:
... yield from om.Void()
This shorthand exists only to satisfy the declared outer callable type; the child jobs still perform the actual flow work.
Outer signature and modifiers
The wrapped callable's parameter list and return annotation define the outer interface of the template.
fixed_params permanently supplies selected callable parameters.
param_key_map renames selected callable parameters to external
keyword names that callers or parent flows use when supplying inputs.
iterate_over_data_files, output_dataset_param, and
output_dataset_cls adapt that outer interface for dataset-wise
iteration.
When iterate_over_data_files=True and the inner first parameter is
annotated as Model[T], callers see an outer
dataset: Dataset[Model[T]] parameter and the outer return type
becomes a dataset of the per-item return type. The inner callable still
receives one model object at a time.
result_key wraps the returned value in a single-key dictionary,
which is especially useful when a downstream DAG step should receive
the result under a predictable name.
Examples:
>>> # With modifiers
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_other(number: int, other: int) -> int:
... return number + other
>>> plus_one = plus_other.refine(fixed_params={'other': 1})
>>> plus_one.run(4)
5
>>> plus_x = plus_other.refine(param_key_map={'other': 'x'})
>>> plus_x.run(4, x=3)
7
>>> plus_one_dict = plus_one.refine(result_key='number')
>>> plus_one_dict.run(4)
{'number': 5}
Examples:
>>> # With dataset-wise iteration
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def add_suffix(
... data_file: TextModel,
... suffix: str,
... ) -> TextModel:
... return f'{data_file.content}{suffix}'
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> add_suffix.run(text_files, suffix='!') == expected
True
Linear orchestration
Linear flows run child jobs strictly in declaration order.
The first child receives the caller's positional and keyword inputs. Each later child receives the previous child result as its leading positional input, plus any matching keyword arguments from the outer flow call.
fixed_params always override caller-supplied values for the child
where they are configured. param_key_map lets later children expose
different external keyword names than their underlying callable
parameter names.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True)
... def strip_text(data_file: TextModel) -> TextModel:
... return data_file.content.strip()
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def add_suffix(
... data_file: TextModel,
... suffix: str,
... ) -> TextModel:
... return f'{data_file.content}{suffix}'
>>> suffix_each = add_suffix.refine(param_key_map={'suffix': 'ending'})
>>> @om.LinearFlowTemplate(strip_text, suffix_each)
... def linear_flow(
... dataset: TextDataset,
... ending: str,
... ) -> TextDataset:
... return dataset
>>> text_files = TextDataset({'a': ' hi', 'b': 'bye '})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> linear_flow.run(text_files, ending='!') == expected
True
Tasks and flows
Tasks are terminal jobs: they wrap one callable and execute one compute step.
Flows are orchestration jobs: they may contain child tasks and child flows, so larger pipelines can be assembled hierarchically from smaller reusable pieces.
Lifecycle
Apply a template with apply()
to create a runnable job with engine decorators and current config attached.
Call the resulting applied job with runtime arguments.
Use run() as a shorthand for
apply() followed immediately by calling the applied job.
Use refine() to reuse a
template while changing configuration such as name, fixed_params,
or param_key_map.
Use revise() on an applied job to
reconstruct a template from that job's current configuration.
Examples:
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_one(number: int) -> int:
... return number + 1
>>> plus_one.run(1)
2
>>> applied_job = plus_one.apply()
>>> applied_job(2)
3
>>> refined_template = plus_one.refine(name='plus_one_renamed')
>>> revised_template = applied_job.revise()
Instances are normally produced through the LinearFlowTemplate decorator factory rather than by direct construction.
| CLASS | DESCRIPTION |
|---|---|
DataClassAndJobParentInfo |
|
| METHOD | DESCRIPTION |
|---|---|
__init__ |
|
accept_mixin |
Register a mixin class for dynamic composition. |
apply |
Create an applied job from this template without executing it. |
create_job_template |
Create a job template instance from the concrete template class. |
log |
Emit a log message, optionally using an explicit event timestamp. |
refine |
Forward refinement to the shared template lifecycle implementation. |
reset_mixins |
Clear all accepted mixins and restore the original init signature. |
run |
Apply the template and execute the resulting job immediately. |
| ATTRIBUTE | DESCRIPTION |
|---|---|
callable_type |
TYPE:
|
child_job_templates |
TYPE:
|
config |
Return the job configuration visible to this instance.
TYPE:
|
engine |
Return the engine associated with this job, if any.
TYPE:
|
in_flow_context |
Return whether the job is currently executing inside a flow context.
TYPE:
|
logger |
Return the logger bound to the concrete instance type.
TYPE:
|
Source code in src/omnipy/compute/flow.py
226 227 228 229 230 231 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 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 | |
config
property
config: IsJobConfig
Return the job configuration visible to this instance.
| RETURNS | DESCRIPTION |
|---|---|
IsJobConfig
|
Active job configuration used for runtime behavior.
TYPE:
|
engine
property
engine: IsEngine | None
Return the engine associated with this job, if any.
| RETURNS | DESCRIPTION |
|---|---|
IsEngine | None
|
IsEngine | None: Engine used for decoration and execution, or |
in_flow_context
property
Return whether the job is currently executing inside a flow context.
| RETURNS | DESCRIPTION |
|---|---|
bool
|
TYPE:
|
logger
property
Return the logger bound to the concrete instance type.
| RETURNS | DESCRIPTION |
|---|---|
Logger
|
Logger used by the object for Omnipy log messages.
TYPE:
|
DataClassAndJobParentInfo
Bases: NamedTuple
flowchart BT
omnipy.compute.flow.LinearFlowTemplateCore.DataClassAndJobParentInfo[DataClassAndJobParentInfo]
click omnipy.compute.flow.LinearFlowTemplateCore.DataClassAndJobParentInfo href "" "omnipy.compute.flow.LinearFlowTemplateCore.DataClassAndJobParentInfo"
| ATTRIBUTE | DESCRIPTION |
|---|---|
dataset_or_model |
TYPE:
|
parent_coerces_from_kwargs |
TYPE:
|
Source code in src/omnipy/compute/_joblist_job.py
__init__
__init__(
job_func: Callable[_CallP, _RetT],
/,
*child_job_templates: ChildJobTemplateLike,
**kwargs: object,
) -> None
Source code in src/omnipy/compute/_joblist_job.py
accept_mixin
classmethod
Register a mixin class for dynamic composition.
| PARAMETER | DESCRIPTION |
|---|---|
mixin_cls
|
Mixin class whose
TYPE:
|
Source code in src/omnipy/util/mixin.py
apply
Create an applied job from this template without executing it.
| RETURNS | DESCRIPTION |
|---|---|
_JobT
|
Applied job instance ready to be called.
TYPE:
|
Source code in src/omnipy/compute/_job.py
create_job_template
classmethod
Create a job template instance from the concrete template class.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional constructor arguments.
TYPE:
|
**kwargs
|
Keyword constructor arguments.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_JobTemplateT
|
New job template instance.
TYPE:
|
Source code in src/omnipy/compute/_job.py
log
Emit a log message, optionally using an explicit event timestamp.
| PARAMETER | DESCRIPTION |
|---|---|
log_msg
|
Message text to send to the logger.
TYPE:
|
level
|
Standard library logging level.
TYPE:
|
datetime_obj
|
Timestamp to attach to the record instead of wall-clock time.
TYPE:
|
Source code in src/omnipy/hub/log/mixin.py
refine
Forward refinement to the shared template lifecycle implementation.
See IsFuncArgJobTemplate.refine and
IsChildJobListArgJobTemplate.refine.
Source code in src/omnipy/compute/_job.py
reset_mixins
classmethod
Clear all accepted mixins and restore the original init signature.
run
Apply the template and execute the resulting job immediately.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional arguments passed to the applied job.
TYPE:
|
**kwargs
|
Keyword arguments passed to the applied job.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
_RetCovT
|
Result returned by the applied job.
TYPE:
|
Source code in src/omnipy/compute/_job.py
DagFlowTemplate
DagFlowTemplate(
*child_job_templates: ChildJobTemplateLike,
consume_kwargs_from_results: bool = True,
iterate_over_data_files: Literal[True],
output_dataset_cls: type[_RetDatasetClsT],
**kwargs: Unpack[JobCommonKwargs],
) -> DagFlowTemplateIterWithDatasetClsDecorator[_RetDatasetClsT]
DagFlowTemplate(
*child_job_templates: ChildJobTemplateLike,
consume_kwargs_from_results: bool = True,
iterate_over_data_files: Literal[True],
output_dataset_cls: None = None,
**kwargs: Unpack[JobCommonKwargs],
) -> DagFlowTemplateIterDecorator
DagFlowTemplate(
*child_job_templates: ChildJobTemplateLike,
consume_kwargs_from_results: bool = True,
iterate_over_data_files: Literal[False] = False,
output_dataset_cls: type[IsDataset] | None = None,
**kwargs: Unpack[JobCommonKwargs],
) -> DagFlowTemplatePlainDecorator
DagFlowTemplate(
*child_job_templates: ChildJobTemplateLike,
consume_kwargs_from_results: bool = True,
iterate_over_data_files: bool,
output_dataset_cls: type[_RetDatasetClsT] | None = None,
**kwargs: Unpack[JobCommonKwargs],
) -> (
DagFlowTemplatePlainDecorator
| DagFlowTemplateIterDecorator
| DagFlowTemplateIterWithDatasetClsDecorator[_RetDatasetClsT]
)
Decorator-style factory for defining directed acyclic graph flows.
A DAG flow template wraps a Python callable together with child job templates whose dependencies form a directed acyclic graph. Use this when flow steps branch and join but must not form cycles.
Decorator usage
Apply the template factory as a decorator to a Python callable. The wrapped callable becomes a reusable job template whose public outer signature is visible to template users and to the applied jobs created from it.
Outer callable and child jobs
The wrapped callable defines the public outer signature of the flow, while the child-job list defines the executed body.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True)
... def uppercase(data_file: TextModel) -> TextModel:
... return data_file.content.upper()
>>> @om.TaskTemplate()
... def join_texts(
... upper: TextDataset,
... original: TextDataset,
... ) -> TextDataset:
... merged = TextDataset()
... for title in upper:
... merged[title] = f'{upper[title].content}|{original[title].content}'
... return merged
>>> @om.DagFlowTemplate(
... uppercase.refine(result_key='upper'),
... join_texts.refine(param_key_map={'upper': 'upper', 'original': 'dataset'}),
... )
... def my_dag(
... dataset: TextDataset,
... ) -> TextDataset:
... return dataset
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({'a': 'HI|hi', 'b': 'BYE|bye'})
>>> my_dag.run(text_files) == expected
True
Child jobs and data classes
Child-job templates may be TaskTemplate or flow-template instances. This lets flows nest other flows as well as terminal tasks.
In linear and DAG flows, Model and Dataset subclasses are also allowed as child-job entries. During apply, they are coerced into helper task templates that construct the requested data object from positional input in linear flows or from keyword-matched input in DAG flows.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.LinearFlowTemplate(TextModel)
... def wrap_text(raw_text: str) -> TextModel:
... return TextModel(raw_text)
>>> wrap_text.run('hello').content
'hello'
>>> @om.DagFlowTemplate(TextDataset)
... def collect_texts(first: str, second: str) -> TextDataset:
... return TextDataset({'first': first, 'second': second})
>>> collect_texts.run(first='hello', second='bye') == TextDataset({
... 'first': 'hello',
... 'second': 'bye',
... })
True
Callable-type validation
For linear and DAG flows, the outer callable is primarily declarative: its signature exposes the public flow interface, while child jobs define the executed body.
The outer callable type is validated against the child-job composition. The terminal child determines whether the flow behaves like a function or generator, and any async child lifts the full flow to an async callable type.
As a result, a sync-function outer callable fits sync child execution,
a generator outer callable fits generator-producing terminal children,
and async outer callables are required when child composition is async.
Mismatches raise TypeError when the flow template is created.
Generator shorthand with Void
When the validated outer callable must be a generator or async-generator only to expose the correct public signature, use Void in the body:
Examples:
>>> @om.LinearFlowTemplate(emit_lines)
... def line_stream() -> Iterator[str]:
... yield from om.Void()
This shorthand exists only to satisfy the declared outer callable type; the child jobs still perform the actual flow work.
Outer signature and modifiers
The wrapped callable's parameter list and return annotation define the outer interface of the template.
fixed_params permanently supplies selected callable parameters.
param_key_map renames selected callable parameters to external
keyword names that callers or parent flows use when supplying inputs.
iterate_over_data_files, output_dataset_param, and
output_dataset_cls adapt that outer interface for dataset-wise
iteration.
When iterate_over_data_files=True and the inner first parameter is
annotated as Model[T], callers see an outer
dataset: Dataset[Model[T]] parameter and the outer return type
becomes a dataset of the per-item return type. The inner callable still
receives one model object at a time.
result_key wraps the returned value in a single-key dictionary,
which is especially useful when a downstream DAG step should receive
the result under a predictable name.
Examples:
>>> # With modifiers
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_other(number: int, other: int) -> int:
... return number + other
>>> plus_one = plus_other.refine(fixed_params={'other': 1})
>>> plus_one.run(4)
5
>>> plus_x = plus_other.refine(param_key_map={'other': 'x'})
>>> plus_x.run(4, x=3)
7
>>> plus_one_dict = plus_one.refine(result_key='number')
>>> plus_one_dict.run(4)
{'number': 5}
Examples:
>>> # With dataset-wise iteration
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def add_suffix(
... data_file: TextModel,
... suffix: str,
... ) -> TextModel:
... return f'{data_file.content}{suffix}'
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> add_suffix.run(text_files, suffix='!') == expected
True
DAG orchestration
DAG flows route values by keyword name instead of chaining every child result positionally.
The outer flow call first binds its arguments to the outer callable signature. Each child then receives the matching keyword subset from the accumulated named results.
By default, a non-dictionary child result is stored under the child job
name. result_key stores it under a custom key instead, which is the
usual way to make one branch feed another. Dictionary results merge
directly into the accumulated named result set.
param_key_map lets a child read from externally visible DAG keys
using different internal callable parameter names, and fixed_params
pins selected child inputs regardless of what earlier branches produce.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate()
... def uppercase(data_file: TextModel) -> TextModel:
... return data_file.content.upper()
>>> @om.TaskTemplate()
... def append_suffix(
... data_file: TextModel,
... suffix: str,
... ) -> TextModel:
... return f'{data_file.content}{suffix}'
>>> @om.TaskTemplate()
... def combine_texts(
... left_dataset: TextDataset,
... right_dataset: TextDataset,
... ) -> TextDataset:
... merged = TextDataset()
... for title in left_dataset:
... merged[title] = (
... f'{left_dataset[title].content}|'
... f'{right_dataset[title].content}'
... )
... return merged
>>> @om.DagFlowTemplate(
... uppercase.refine(
... iterate_over_data_files=True,
... result_key='upper',
... ),
... append_suffix.refine(
... iterate_over_data_files=True,
... result_key='suffixed',
... param_key_map={'suffix': 'ending'},
... ),
... combine_texts.refine(
... param_key_map={
... 'left_dataset': 'upper',
... 'right_dataset': 'suffixed',
... },
... ),
... )
... def dag_flow(
... dataset: TextDataset,
... ending: str,
... ) -> TextDataset:
... return dataset
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({
... 'a': 'HI|hi!',
... 'b': 'BYE|bye!',
... })
>>> dag_flow.run(text_files, ending='!') == expected
True
Tasks and flows
Tasks are terminal jobs: they wrap one callable and execute one compute step.
Flows are orchestration jobs: they may contain child tasks and child flows, so larger pipelines can be assembled hierarchically from smaller reusable pieces.
Lifecycle
Apply a template with apply()
to create a runnable job with engine decorators and current config attached.
Call the resulting applied job with runtime arguments.
Use run() as a shorthand for
apply() followed immediately by calling the applied job.
Use refine() to reuse a
template while changing configuration such as name, fixed_params,
or param_key_map.
Use revise() on an applied job to
reconstruct a template from that job's current configuration.
Examples:
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_one(number: int) -> int:
... return number + 1
>>> plus_one.run(1)
2
>>> applied_job = plus_one.apply()
>>> applied_job(2)
3
>>> refined_template = plus_one.refine(name='plus_one_renamed')
>>> revised_template = applied_job.revise()
| PARAMETER | DESCRIPTION |
|---|---|
*child_job_templates
|
Ordered templates of child jobs to be run as part of the parent job. Model and Dataset subclasses are also allowed, in which case they are converted to create_X_from_args (if linear flow) or create_X_from_kwargs (if DAG flow) job templates, respectively, when apply() is called on the parent job template.
TYPE:
|
consume_kwargs_from_results
|
Whether keyword arguments matched by a child job should be removed from the accumulated DAG results before later child jobs are matched.
TYPE:
|
name
|
Name of the job template. If not provided, the name of the wrapped callable is used.
TYPE:
|
iterate_over_data_files
|
Whether dataset inputs should be processed item-wise.
TYPE:
|
output_dataset_param
|
Optional name of an explicit output-dataset parameter.
TYPE:
|
output_dataset_cls
|
Optional dataset class to use for iterated outputs.
TYPE:
|
auto_async
|
Whether coroutine jobs at the outermost level (not in a flow context) should be automatically run in accordance with context (use existing event loop, if available, otherwise create temporary event loop and run coroutine until completion).
TYPE:
|
result_key
|
Optional key used to wrap the returned result in a dictionary. Especially useful in DAG flows to avoid name collisions.
TYPE:
|
fixed_params
|
Fixed keyword-argument values for the job. May not target args or *kwargs-style params.
TYPE:
|
param_key_map
|
Mapping from callable parameter names to external keyword names. May not target args or *kwargs-style params.
TYPE:
|
persist_outputs
|
Per-job output-persistence preference.
TYPE:
|
restore_outputs
|
Per-job output-restore preference.
TYPE:
|
**kwargs
|
Additional constructor keyword overrides.
TYPE:
|
Returns:
DagFlowTemplate: New DagFlowTemplate instance wrapping job_func.
Source code in src/omnipy/compute/flow.py
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 | |
FuncFlowTemplate
FuncFlowTemplate(
*,
iterate_over_data_files: Literal[True],
output_dataset_cls: type[_RetDatasetClsT],
**kwargs: Unpack[JobCommonKwargs],
) -> FuncFlowTemplateIterWithDatasetClsDecorator[_RetDatasetClsT]
FuncFlowTemplate(
*,
iterate_over_data_files: Literal[True],
output_dataset_cls: None = None,
**kwargs: Unpack[JobCommonKwargs],
) -> FuncFlowTemplateIterDecorator
FuncFlowTemplate(
*,
iterate_over_data_files: Literal[False] = False,
output_dataset_cls: type[IsDataset] | None = None,
**kwargs: Unpack[JobCommonKwargs],
) -> FuncFlowTemplatePlainDecorator
Decorator-style factory for defining callable-backed coordinating flows.
A function flow template wraps a Python callable that orchestrates work as a flow. Use this when the control flow is easiest to express directly in Python instead of as an explicit task list or dependency graph.
Decorator usage
Apply the template factory as a decorator to a Python callable. The wrapped callable becomes a reusable job template whose public outer signature is visible to template users and to the applied jobs created from it.
Wrapped callable
The wrapped callable defines both the implementation and the public outer signature of the flow.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.FuncFlowTemplate()
... def append_suffix_to_all(
... dataset: TextDataset,
... suffix: str,
... ) -> TextDataset:
... output_dataset = TextDataset()
... for title, data_file in dataset.items():
... output_dataset[title] = f'{data_file.content}{suffix}'
... return output_dataset
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> append_suffix_to_all.run(text_files, '!') == expected
True
Outer signature and modifiers
The wrapped callable's parameter list and return annotation define the outer interface of the template.
fixed_params permanently supplies selected callable parameters.
param_key_map renames selected callable parameters to external
keyword names that callers or parent flows use when supplying inputs.
iterate_over_data_files, output_dataset_param, and
output_dataset_cls adapt that outer interface for dataset-wise
iteration.
When iterate_over_data_files=True and the inner first parameter is
annotated as Model[T], callers see an outer
dataset: Dataset[Model[T]] parameter and the outer return type
becomes a dataset of the per-item return type. The inner callable still
receives one model object at a time.
result_key wraps the returned value in a single-key dictionary,
which is especially useful when a downstream DAG step should receive
the result under a predictable name.
Examples:
>>> # With modifiers
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_other(number: int, other: int) -> int:
... return number + other
>>> plus_one = plus_other.refine(fixed_params={'other': 1})
>>> plus_one.run(4)
5
>>> plus_x = plus_other.refine(param_key_map={'other': 'x'})
>>> plus_x.run(4, x=3)
7
>>> plus_one_dict = plus_one.refine(result_key='number')
>>> plus_one_dict.run(4)
{'number': 5}
Examples:
>>> # With dataset-wise iteration
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def add_suffix(
... data_file: TextModel,
... suffix: str,
... ) -> TextModel:
... return f'{data_file.content}{suffix}'
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> add_suffix.run(text_files, suffix='!') == expected
True
Tasks and flows
Tasks are terminal jobs: they wrap one callable and execute one compute step.
Flows are orchestration jobs: they may contain child tasks and child flows, so larger pipelines can be assembled hierarchically from smaller reusable pieces.
Lifecycle
Apply a template with apply()
to create a runnable job with engine decorators and current config attached.
Call the resulting applied job with runtime arguments.
Use run() as a shorthand for
apply() followed immediately by calling the applied job.
Use refine() to reuse a
template while changing configuration such as name, fixed_params,
or param_key_map.
Use revise() on an applied job to
reconstruct a template from that job's current configuration.
Examples:
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_one(number: int) -> int:
... return number + 1
>>> plus_one.run(1)
2
>>> applied_job = plus_one.apply()
>>> applied_job(2)
3
>>> refined_template = plus_one.refine(name='plus_one_renamed')
>>> revised_template = applied_job.revise()
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Name of the job template. If not provided, the name of the wrapped callable is used.
TYPE:
|
iterate_over_data_files
|
Whether dataset inputs should be processed item-wise.
TYPE:
|
output_dataset_param
|
Optional name of an explicit output-dataset parameter.
TYPE:
|
output_dataset_cls
|
Optional dataset class to use for iterated outputs.
TYPE:
|
auto_async
|
Whether coroutine jobs at the outermost level (not in a flow context) should be automatically run in accordance with context (use existing event loop, if available, otherwise create temporary event loop and run coroutine until completion).
TYPE:
|
result_key
|
Optional key used to wrap the returned result in a dictionary. Especially useful in DAG flows to avoid name collisions.
TYPE:
|
fixed_params
|
Fixed keyword-argument values for the job. May not target args or *kwargs-style params.
TYPE:
|
param_key_map
|
Mapping from callable parameter names to external keyword names. May not target args or *kwargs-style params.
TYPE:
|
persist_outputs
|
Per-job output-persistence preference.
TYPE:
|
restore_outputs
|
Per-job output-restore preference.
TYPE:
|
**kwargs
|
Additional constructor keyword overrides.
TYPE:
|
Returns:
FuncFlowTemplate: New FuncFlowTemplate instance wrapping job_func.
-
Reference
Code reference
omnipy
compute
flowFuncFlowTemplateCore
Source code in src/omnipy/compute/flow.py
1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 | |
LinearFlowTemplate
LinearFlowTemplate(
*child_job_templates: ChildJobTemplateLike,
iterate_over_data_files: Literal[True],
output_dataset_cls: type[_RetDatasetClsT],
**kwargs: Unpack[JobCommonKwargs],
) -> LinearFlowTemplateIterWithDatasetClsDecorator[_RetDatasetClsT]
LinearFlowTemplate(
*child_job_templates: ChildJobTemplateLike,
iterate_over_data_files: Literal[True],
output_dataset_cls: None = None,
**kwargs: Unpack[JobCommonKwargs],
) -> LinearFlowTemplateIterDecorator
LinearFlowTemplate(
*child_job_templates: ChildJobTemplateLike,
iterate_over_data_files: Literal[False] = False,
output_dataset_cls: type[IsDataset] | None = None,
**kwargs: Unpack[JobCommonKwargs],
) -> LinearFlowTemplatePlainDecorator
LinearFlowTemplate(
*child_job_templates: ChildJobTemplateLike,
iterate_over_data_files: bool,
output_dataset_cls: type[_RetDatasetClsT] | None = None,
**kwargs: Unpack[JobCommonKwargs],
) -> (
LinearFlowTemplatePlainDecorator
| LinearFlowTemplateIterDecorator
| LinearFlowTemplateIterWithDatasetClsDecorator[_RetDatasetClsT]
)
Decorator-style factory for defining sequential flows.
A linear flow template wraps a Python callable together with an ordered list of child job templates that run sequentially. Use this when work should proceed step by step in a fixed declaration order.
Decorator usage
Apply the template factory as a decorator to a Python callable. The wrapped callable becomes a reusable job template whose public outer signature is visible to template users and to the applied jobs created from it.
Outer callable and child jobs
The wrapped callable defines the public outer signature of the flow, while the child-job list defines the executed body.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def normalize_text(data_file: TextModel) -> TextModel:
... return data_file.content.strip().lower()
>>> @om.LinearFlowTemplate(normalize_text)
... def clean_texts(
... dataset: TextDataset,
... ) -> TextDataset:
... return dataset
>>> text_files = TextDataset({'a': ' Hi ', 'b': 'BYE '})
>>> expected = TextDataset({'a': 'hi', 'b': 'bye'})
>>> clean_texts.run(text_files) == expected
True
Child jobs and data classes
Child-job templates may be TaskTemplate or flow-template instances. This lets flows nest other flows as well as terminal tasks.
In linear and DAG flows, Model and Dataset subclasses are also allowed as child-job entries. During apply, they are coerced into helper task templates that construct the requested data object from positional input in linear flows or from keyword-matched input in DAG flows.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.LinearFlowTemplate(TextModel)
... def wrap_text(raw_text: str) -> TextModel:
... return TextModel(raw_text)
>>> wrap_text.run('hello').content
'hello'
>>> @om.DagFlowTemplate(TextDataset)
... def collect_texts(first: str, second: str) -> TextDataset:
... return TextDataset({'first': first, 'second': second})
>>> collect_texts.run(first='hello', second='bye') == TextDataset({
... 'first': 'hello',
... 'second': 'bye',
... })
True
Callable-type validation
For linear and DAG flows, the outer callable is primarily declarative: its signature exposes the public flow interface, while child jobs define the executed body.
The outer callable type is validated against the child-job composition. The terminal child determines whether the flow behaves like a function or generator, and any async child lifts the full flow to an async callable type.
As a result, a sync-function outer callable fits sync child execution,
a generator outer callable fits generator-producing terminal children,
and async outer callables are required when child composition is async.
Mismatches raise TypeError when the flow template is created.
Generator shorthand with Void
When the validated outer callable must be a generator or async-generator only to expose the correct public signature, use Void in the body:
Examples:
>>> @om.LinearFlowTemplate(emit_lines)
... def line_stream() -> Iterator[str]:
... yield from om.Void()
This shorthand exists only to satisfy the declared outer callable type; the child jobs still perform the actual flow work.
Outer signature and modifiers
The wrapped callable's parameter list and return annotation define the outer interface of the template.
fixed_params permanently supplies selected callable parameters.
param_key_map renames selected callable parameters to external
keyword names that callers or parent flows use when supplying inputs.
iterate_over_data_files, output_dataset_param, and
output_dataset_cls adapt that outer interface for dataset-wise
iteration.
When iterate_over_data_files=True and the inner first parameter is
annotated as Model[T], callers see an outer
dataset: Dataset[Model[T]] parameter and the outer return type
becomes a dataset of the per-item return type. The inner callable still
receives one model object at a time.
result_key wraps the returned value in a single-key dictionary,
which is especially useful when a downstream DAG step should receive
the result under a predictable name.
Examples:
>>> # With modifiers
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_other(number: int, other: int) -> int:
... return number + other
>>> plus_one = plus_other.refine(fixed_params={'other': 1})
>>> plus_one.run(4)
5
>>> plus_x = plus_other.refine(param_key_map={'other': 'x'})
>>> plus_x.run(4, x=3)
7
>>> plus_one_dict = plus_one.refine(result_key='number')
>>> plus_one_dict.run(4)
{'number': 5}
Examples:
>>> # With dataset-wise iteration
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def add_suffix(
... data_file: TextModel,
... suffix: str,
... ) -> TextModel:
... return f'{data_file.content}{suffix}'
>>> text_files = TextDataset({'a': 'hi', 'b': 'bye'})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> add_suffix.run(text_files, suffix='!') == expected
True
Linear orchestration
Linear flows run child jobs strictly in declaration order.
The first child receives the caller's positional and keyword inputs. Each later child receives the previous child result as its leading positional input, plus any matching keyword arguments from the outer flow call.
fixed_params always override caller-supplied values for the child
where they are configured. param_key_map lets later children expose
different external keyword names than their underlying callable
parameter names.
Examples:
>>> import omnipy as om
>>> class TextModel(om.Model[str]): ...
>>> class TextDataset(om.Dataset[TextModel]): ...
>>> @om.TaskTemplate(iterate_over_data_files=True)
... def strip_text(data_file: TextModel) -> TextModel:
... return data_file.content.strip()
>>> @om.TaskTemplate(iterate_over_data_files=True, output_dataset_cls=TextDataset)
... def add_suffix(
... data_file: TextModel,
... suffix: str,
... ) -> TextModel:
... return f'{data_file.content}{suffix}'
>>> suffix_each = add_suffix.refine(param_key_map={'suffix': 'ending'})
>>> @om.LinearFlowTemplate(strip_text, suffix_each)
... def linear_flow(
... dataset: TextDataset,
... ending: str,
... ) -> TextDataset:
... return dataset
>>> text_files = TextDataset({'a': ' hi', 'b': 'bye '})
>>> expected = TextDataset({'a': 'hi!', 'b': 'bye!'})
>>> linear_flow.run(text_files, ending='!') == expected
True
Tasks and flows
Tasks are terminal jobs: they wrap one callable and execute one compute step.
Flows are orchestration jobs: they may contain child tasks and child flows, so larger pipelines can be assembled hierarchically from smaller reusable pieces.
Lifecycle
Apply a template with apply()
to create a runnable job with engine decorators and current config attached.
Call the resulting applied job with runtime arguments.
Use run() as a shorthand for
apply() followed immediately by calling the applied job.
Use refine() to reuse a
template while changing configuration such as name, fixed_params,
or param_key_map.
Use revise() on an applied job to
reconstruct a template from that job's current configuration.
Examples:
>>> import omnipy as om
>>> @om.TaskTemplate()
... def plus_one(number: int) -> int:
... return number + 1
>>> plus_one.run(1)
2
>>> applied_job = plus_one.apply()
>>> applied_job(2)
3
>>> refined_template = plus_one.refine(name='plus_one_renamed')
>>> revised_template = applied_job.revise()
| PARAMETER | DESCRIPTION |
|---|---|
*child_job_templates
|
Ordered templates of child jobs to be run as part of the parent job. Model and Dataset subclasses are also allowed, in which case they are converted to create_X_from_args (if linear flow) or create_X_from_kwargs (if DAG flow) job templates, respectively, when apply() is called on the parent job template.
TYPE:
|
name
|
Name of the job template. If not provided, the name of the wrapped callable is used.
TYPE:
|
iterate_over_data_files
|
Whether dataset inputs should be processed item-wise.
TYPE:
|
output_dataset_param
|
Optional name of an explicit output-dataset parameter.
TYPE:
|
output_dataset_cls
|
Optional dataset class to use for iterated outputs.
TYPE:
|
auto_async
|
Whether coroutine jobs at the outermost level (not in a flow context) should be automatically run in accordance with context (use existing event loop, if available, otherwise create temporary event loop and run coroutine until completion).
TYPE:
|
result_key
|
Optional key used to wrap the returned result in a dictionary. Especially useful in DAG flows to avoid name collisions.
TYPE:
|
fixed_params
|
Fixed keyword-argument values for the job. May not target args or *kwargs-style params.
TYPE:
|
param_key_map
|
Mapping from callable parameter names to external keyword names. May not target args or *kwargs-style params.
TYPE:
|
persist_outputs
|
Per-job output-persistence preference.
TYPE:
|
restore_outputs
|
Per-job output-restore preference.
TYPE:
|
**kwargs
|
Additional constructor keyword overrides.
TYPE:
|
Returns:
LinearFlowTemplate: New LinearFlowTemplate instance wrapping job_func.
-
Reference
Code reference
omnipy
compute
flowLinearFlowTemplateCore
Source code in src/omnipy/compute/flow.py
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 | |