a simple workflow engine
Project description
workflowlite
pip install workflowlite
A workflow engine that allows the execution of jobs composed of multiple steps. Each step is defined by an action and a set of inputs and outputs.
The job definition can include on_except and on_finish hooks to handle the job's completion or failure.
The context is updated during execution with runtime information like job_run_id and job_status.
All the system variables are prefixed with $.
Example Usage:
from workflowlite import WorkflowEngine, Context
engine = WorkflowEngine()
@engine.register_action('prepare')
def prepare(inputs: List[str], context: Context):
context['prepared_output'] = "prepared_output.mp4"
@engine.register_action('ffmpeg')
def ffmpeg(inputs: List[str], context: Context):
context['mp3_output'] = "output.mp3"
@engine.register_hook('on_finish')
def on_finish(context: Context):
print("Job finished successfully!")
@engine.register_hook('on_except')
def on_except(context: Context):
print("Job encountered an exception.")
job = {
"name": "video_processing",
"env": {"input_file": "video.mp4"},
"steps": [
{
"action": "prepare",
"input": ["input_file"],
"output": ["prepared_output"]
},
{
"action": "ffmpeg",
"input": ["prepared_output"],
"output": ["mp3_output"]
}
],
"output": ["mp3_output"],
"on_finish": "on_finish",
"on_except": "on_except"
}
with engine:
job_future = engine.submit_job(job)
try:
result = job_future.wait()
print(f"Job completed with output: {result}")
except Exception as e:
print(f"Job failed with exception: {e}")
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
workflowlite-0.2.3.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for workflowlite-0.2.3-py3-none-any.whl
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 | e50dfc3104bba965375eda9f5ca4b3432436c0f4759d98b5ff3e9418a0234131 |
|
| MD5 | 41b24a87bfa215652f4d619223f052ee |
|
| BLAKE2b-256 | d9375c733ff35085cddc151d0a3eb359661d0973afe7897d2efb820cd14ba9f8 |