API Reference¶
Auto-generated from the source docstrings. For task-writing guidance start with the Guide; this page is the exhaustive symbol reference.
Top-level API¶
The public API re-exported from oryxflow — run, preview, Workflow, WorkflowMulti,
the requires / inherits decorators, the Parameter types, and the invalidate_* /
enable_* helpers.
Engine — oryxflow.core¶
oryxflow.core ¶
Mini-engine: a small, self-contained execution engine for oryxflow. Provides the Task base
class, target bases, flatten/getpaths, deterministic task ids, the
inherits/requires decorators, find_deps and a sequential build.
The execution engine is sequential: the DAG is run in dependency order in-process. The
workers argument is accepted for API compatibility but ignored.
Register ¶
Bases: type
Minimal metaclass providing a class-level task_family property and instance memoization.
A property defined directly on class:
Task is only invoked for instances; reading
SomeTaskClass.task_family needs this metaclass property (used eg by WorkflowMulti).
__call__ memoizes instances so two Cls(**same_params) calls return the identical
object (and __init__ runs only on the first), preserving the instance identity that
Workflow's path/flow propagation depends on.
Source code in oryxflow/core.py
Task ¶
Base class for all oryxflow tasks.
Subclasses declare class:
~oryxflow.parameter.Parameter members and override
meth:
run, meth:
requires and meth:
output.
Source code in oryxflow/core.py
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 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 | |
logger
property
¶
Contextual logger for task authors; auto-tagged with task identity.
Lives in the oryxflow namespace, so it is silent until
oryxflow.enable_logging() is called.
get_params
classmethod
¶
Return all (name, Parameter) pairs for this task, in declaration order.
Source code in oryxflow/core.py
get_param_names
classmethod
¶
Return parameter names. include_significant=True returns all params.
get_param_values
classmethod
¶
Resolve parameter values from positional args, kwargs and defaults.
:param params: list of (param_name, Parameter)
:param args: positional arguments
:param kwargs: keyword arguments
:returns: list of (name, value) tuples, one per parameter
Source code in oryxflow/core.py
get_task_family
classmethod
¶
to_str_params ¶
Convert parameters to a {name: serialized_value} dict.
:param bool only_significant: only include parameters marked significant. :param bool only_public: accepted for API compatibility; visibility is not modeled.
Source code in oryxflow/core.py
clone ¶
Create a new task instance from this one, overriding some args.
Parameters common to this task and cls are carried over; kwargs take precedence.
Source code in oryxflow/core.py
complete ¶
True if all of this task's outputs exist.
Note: TaskData OVERRIDES this to ALSO require the stored code
fingerprint to match the current one (TaskData._code_ok), so a
code_version bump makes a task incomplete and forces a rerun -- the
fingerprint is authoritative here, not merely advisory. The AST
source-hash is a SEPARATE, warn-only advisory (fires when code changed
but code_version did not); it does not gate completeness.
Source code in oryxflow/core.py
output ¶
requires ¶
input ¶
deps ¶
Target ¶
LocalTarget ¶
Bases: Target
Tiny local target base.
self.path is stored as-is (NOT coerced to str); subclasses
(CacheTarget/_LocalPathTarget) override the rest and normalize the path.
Source code in oryxflow/core.py
inherits ¶
Copy parameters (and nothing else) from one or more task classes onto the decorated task,
and add clone_parent/clone_parents helpers. Avoids pythonic inheritance.
Supports positional tasks (clone_parents returns a list) or named tasks via keyword
arguments (clone_parents returns a dict).
Source code in oryxflow/core.py
requires ¶
Same as class:
inherits, but also auto-defines the requires method.
Source code in oryxflow/core.py
TaskFailure ¶
One failed task: the task instance plus why it failed.
Source code in oryxflow/core.py
RunResult ¶
What happened to the DAG in one build: identities, status, failure context.
Source code in oryxflow/core.py
MultiRunResult ¶
Bases: dict
Return value of WorkflowMulti.run(): a {flow_name: RunResult} dict that also
carries .summary()/.success so print(result.summary()) works the same as for a
single Workflow (whose run() returns a plain class:
RunResult).
Source code in oryxflow/core.py
summary ¶
Per-flow execution summaries, each under a ===== <flow> ===== header.
flatten ¶
Create a flat list of all items in a structured object (dicts, lists, items)::
>>> sorted(flatten({'a': 'foo', 'b': 'bar'}))
['bar', 'foo']
>>> sorted(flatten(['foo', ['bar', 'troll']]))
['bar', 'foo', 'troll']
>>> flatten('foo')
['foo']
>>> flatten(42)
[42]
Source code in oryxflow/core.py
getpaths ¶
Map all Tasks in a structured object to their .output().
Source code in oryxflow/core.py
task_id_str ¶
Return a canonical, deterministic string identifying a task.
The id is {family}_{param_summary}_{md5(sorted_json)[:10]} so that
task_id.split('_')[0] yields the task family (the directory convention).
:param task_family: the task family (class name) :param params: dict mapping parameter names to serialized (str) values
Source code in oryxflow/core.py
dfs_paths ¶
Yield tasks on every dependency path from start_task to goal_task_family.
Source code in oryxflow/core.py
find_deps ¶
Return the set of all tasks on all paths between task and upstream_task_family.
build ¶
Run tasks and their dependencies sequentially, in dependency order.
All state is local to this call, so a task's run() may itself call oryxflow.run /
flow.run (the flow-within-a-flow pattern) without corrupting the outer build.
External tasks (external=True or run is None) are never executed; if still
incomplete after their dependencies, they are marked failed.
:param flow: flow name when launched via Workflow/WorkflowMulti; stamped into
this build's event envelopes.
:returns: a class:
RunResult with .ran/.complete/.failed task identities,
.success, .run_id, per-task .reasons and code-change .warnings.
Source code in oryxflow/core.py
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 | |
Parameters — oryxflow.parameter¶
oryxflow.parameter ¶
Self-contained, trimmed set of parameter types used by oryxflow.
There is no command-line / config-file value resolution, parameter visibility,
date_interval, freezing (FrozenOrderedDict) or jsonschema support. Values
are resolved from the constructor argument or the default only.
Only the parameter types oryxflow actually uses are kept:
Parameter, IntParameter, FloatParameter, BoolParameter, DateParameter,
DictParameter, ListParameter, ChoiceParameter and EnumParameter.
ParameterException ¶
MissingParameterException ¶
Bases: ParameterException
Raised when a required parameter has no value and no default.
UnknownParameterException ¶
Bases: ParameterException
Raised when an unknown parameter is supplied to a task.
DuplicateParameterException ¶
Bases: ParameterException
Raised when a parameter is supplied both positionally and as a keyword.
Parameter ¶
Parameter whose value is a str, and the base class for the other parameter types.
Parameters are set on the Task class to parameterize tasks::
class MyTask(oryxflow.tasks.TaskData):
foo = oryxflow.Parameter()
When a value is not provided at instantiation, the default is used.
Source code in oryxflow/parameter.py
IntParameter ¶
FloatParameter ¶
BoolParameter ¶
Bases: Parameter
A Parameter whose value is a bool. Has an implicit default of False.
Source code in oryxflow/parameter.py
parse ¶
Parse a bool from the string, matching 'true'/'false' case-insensitively.
Source code in oryxflow/parameter.py
DateParameter ¶
Bases: Parameter
Parameter whose value is a class:
~datetime.date, formatted YYYY-MM-DD.
Source code in oryxflow/parameter.py
DictParameter ¶
Bases: Parameter
Parameter whose value is a dict.
The value is stored as-is (no freezing); it is serialized with sorted keys so that the task id stays deterministic.
Source code in oryxflow/parameter.py
ListParameter ¶
Bases: Parameter
Parameter whose value is a list.
The value is stored as-is (no freezing); it is serialized as JSON so that the task id stays deterministic.
Source code in oryxflow/parameter.py
ChoiceParameter ¶
Bases: Parameter
A string-valued parameter restricted to a fixed set of choices::
class MyTask(oryxflow.tasks.TaskData):
model = oryxflow.ChoiceParameter(choices=['rf', 'lgbm'], default='rf')
Values stay plain strings (no enum.Enum ceremony, unlike
:class:EnumParameter); a value outside choices raises immediately at task
construction (or when the default is resolved), so typos fail fast instead of
dying deep in downstream code.
Source code in oryxflow/parameter.py
EnumParameter ¶
Bases: Parameter
A parameter whose value is an :class:~enum.Enum. Pass the enum class via enum=::
class Model(enum.Enum):
Honda = 1
Volvo = 2
class MyTask(oryxflow.tasks.TaskData):
my_param = oryxflow.EnumParameter(enum=Model)
Source code in oryxflow/parameter.py
Tasks — oryxflow.tasks¶
oryxflow.tasks ¶
TaskData ¶
Bases: Task
Task which has data as input and output
Attributes:
| Name | Type | Description |
|---|---|---|
target_class |
obj
|
target data format |
target_ext |
str
|
file extension |
persists |
list
|
list of strings naming the outputs this task saves.
Declare it on your task class, e.g. |
data |
dict
|
data container for all outputs |
Source code in oryxflow/tasks/__init__.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 95 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 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 | |
reset ¶
invalidate ¶
Reset a task, eg by deleting output file
Source code in oryxflow/tasks/__init__.py
complete ¶
Check if a task is complete: output exists AND the stored code fingerprint
matches the current one (_code_ok -- a code_version bump makes the
task incomplete and forces a rerun; authoritative, unlike the warn-only AST
source-hash advisory). With check_dependencies, cascades upstream.
Source code in oryxflow/tasks/__init__.py
output ¶
Output target(s) this task produces
Source code in oryxflow/tasks/__init__.py
inputLoad ¶
Load all or several outputs from task
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
list
|
list of data to load |
None
|
task
|
str
|
if requires multiple tasks load that task 'input1' for eg |
None
|
cached
|
bool
|
cache data in memory |
False
|
as_dict
|
bool
|
if the inputs were saved as a dictionary. use this to return them as dictionary. |
False
|
Returns: list or dict of all task output
Source code in oryxflow/tasks/__init__.py
inputLoadConcat ¶
Load every dependency and concatenate into one DataFrame. Works for the dict form of requires() ({key: Task(...)}) and the list/positional form. By default each dependency's significant params are added as columns. concat_fn(identifier, params, df)->df overrides.
Source code in oryxflow/tasks/__init__.py
outputLoad ¶
Load all or several outputs from task
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
list
|
list of data to load |
None
|
as_dict
|
bool
|
cache data in memory |
False
|
cached
|
bool
|
cache data in memory |
False
|
Returns: list or dict of all task output
Source code in oryxflow/tasks/__init__.py
save ¶
Persist data to target
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
data to save. keys are the self.persist keys and values is data |
required |
Source code in oryxflow/tasks/__init__.py
TaskCache ¶
TaskCachePandas ¶
TaskJson ¶
TaskPickle ¶
TaskCSVPandas ¶
TaskCSVGZPandas ¶
TaskExcelPandasSingle ¶
Bases: TaskData
Task which saves each persist key as a separate Excel file
Source code in oryxflow/tasks/__init__.py
TaskExcelPandas ¶
Bases: TaskData
Task which saves multiple dataframes as sheets in a single Excel file
Source code in oryxflow/tasks/__init__.py
TaskPqPandas ¶
TaskMarkdown ¶
TaskAggregator ¶
Bases: Task
Task which yields other tasks
NB: Use this function by implementing run() which should do nothing but yield other tasks
example::
class TaskCollector(oryxflow.tasks.TaskAggregator):
def run(self):
yield Task1()
yield Task2()
Source code in oryxflow/tasks/__init__.py
Targets — oryxflow.targets¶
oryxflow.targets ¶
CacheTarget ¶
Bases: LocalTarget
Saves to in-memory cache, loads to python object
Source code in oryxflow/targets/__init__.py
DataTarget ¶
Bases: _LocalPathTarget
Local target which saves in-memory data (eg dataframes) to persistent storage (eg files) and loads from storage to memory
This is an abstract class that you should extend.
Source code in oryxflow/targets/__init__.py
load ¶
Runs a function to load data from storage into memory
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fun
|
function
|
loading function |
required |
cached
|
bool
|
keep data cached in memory |
False
|
**kwargs
|
arguments to pass to |
{}
|
Returns: data object
Source code in oryxflow/targets/__init__.py
save ¶
Runs a function to save data from memory into storage
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
obj
|
data to save |
required |
fun
|
function
|
saving function |
required |
**kwargs
|
arguments to pass to |
{}
|
Returns: filename
Source code in oryxflow/targets/__init__.py
CSVPandasTarget ¶
Bases: DataTarget
Saves to CSV, loads to pandas dataframe
Source code in oryxflow/targets/__init__.py
load ¶
Load from csv to pandas dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cached
|
bool
|
keep data cached in memory |
False
|
**kwargs
|
arguments to pass to pd.read_csv |
{}
|
Returns: pandas dataframe
Source code in oryxflow/targets/__init__.py
save ¶
Save dataframe to csv
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
obj
|
pandas dataframe |
required |
**kwargs
|
dict
|
additional arguments to pass to df.to_csv |
{}
|
Returns: filename
Source code in oryxflow/targets/__init__.py
CSVGZPandasTarget ¶
Bases: CSVPandasTarget
Saves to CSV gzip, loads to pandas dataframe
Source code in oryxflow/targets/__init__.py
save ¶
Save dataframe to csv gzip
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
obj
|
pandas dataframe |
required |
**kwargs
|
dict
|
additional arguments to pass to df.to_csv |
{}
|
Returns: filename
Source code in oryxflow/targets/__init__.py
ExcelPandasTarget ¶
Bases: DataTarget
Saves to Excel, loads to pandas dataframe
Source code in oryxflow/targets/__init__.py
load ¶
Load from Excel to pandas dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cached
|
bool
|
keep data cached in memory |
False
|
**kwargs
|
arguments to pass to pd.read_csv |
{}
|
Returns: pandas dataframe
Source code in oryxflow/targets/__init__.py
save ¶
Save dataframe to Excel
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
obj
|
pandas dataframe |
required |
**kwargs
|
dict
|
additional arguments to pass to df.to_csv |
{}
|
Returns: filename
Source code in oryxflow/targets/__init__.py
ExcelPandasSheetsTarget ¶
Bases: _LocalPathTarget
Saves dict of dataframes as sheets in a single Excel file, loads selectively by sheet
Source code in oryxflow/targets/__init__.py
load ¶
Load sheets from Excel file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
keys
|
str / list
|
sheet name(s) to load. None loads all sheets |
None
|
cached
|
bool
|
keep data cached in memory |
False
|
**kwargs
|
arguments to pass to pd.read_excel |
{}
|
Returns: dict of dataframes, single dataframe, or filtered dict
Source code in oryxflow/targets/__init__.py
save ¶
Save dict of dataframes as sheets in a single Excel file
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
{sheet_name: dataframe} |
required |
kwargs
|
additional arguments to pass to df.to_excel |
{}
|
Returns: filename
Source code in oryxflow/targets/__init__.py
PqPandasTarget ¶
Bases: DataTarget
Saves to parquet, loads to pandas dataframe
Source code in oryxflow/targets/__init__.py
load ¶
Load from parquet to pandas dataframe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cached
|
bool
|
keep data cached in memory |
False
|
**kwargs
|
arguments to pass to pd.read_parquet |
{}
|
Returns: pandas dataframe
Source code in oryxflow/targets/__init__.py
save ¶
Save dataframe to parquet
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
obj
|
pandas dataframe |
required |
**kwargs
|
dict
|
additional arguments to pass to df.to_parquet |
{}
|
Returns: filename
Source code in oryxflow/targets/__init__.py
JsonTarget ¶
Bases: DataTarget
Saves to json, loads to dict
Source code in oryxflow/targets/__init__.py
load ¶
Load from json to dict
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cached
|
bool
|
keep data cached in memory |
False
|
**kwargs
|
arguments to pass to json.load |
{}
|
Returns: dict
Source code in oryxflow/targets/__init__.py
save ¶
Save dict to json
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dict_
|
dict
|
python dict |
required |
**kwargs
|
dict
|
additional arguments to pass to json.dump |
{}
|
Returns: filename
Source code in oryxflow/targets/__init__.py
MarkdownTarget ¶
Bases: DataTarget
Saves to markdown (.md) and HTML (.html), loads markdown string
Source code in oryxflow/targets/__init__.py
load ¶
Load from markdown file to string
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cached
|
bool
|
keep data cached in memory |
False
|
**kwargs
|
arguments to pass to read function |
{}
|
Returns: markdown string
Source code in oryxflow/targets/__init__.py
save ¶
Save markdown string to .md and .html files
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
md_string
|
str
|
markdown string |
required |
**kwargs
|
dict
|
additional arguments to pass to markdown.markdown |
{}
|
Returns: filename
Source code in oryxflow/targets/__init__.py
PickleTarget ¶
Bases: DataTarget
Saves to pickle, loads to python obj
Source code in oryxflow/targets/__init__.py
load ¶
Load from pickle to obj
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cached
|
bool
|
keep data cached in memory |
False
|
**kwargs
|
arguments to pass to pickle.load |
{}
|
Returns: dict
Source code in oryxflow/targets/__init__.py
save ¶
Save obj to pickle
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
obj
|
python object |
required |
**kwargs
|
dict
|
additional arguments to pass to pickle.dump |
{}
|
Returns: filename