Skip to main content

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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

workflowlite-0.2.3-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file workflowlite-0.2.3.tar.gz.

File metadata

  • Download URL: workflowlite-0.2.3.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for workflowlite-0.2.3.tar.gz
Algorithm Hash digest
SHA256 5007475d0b28024638d9cd7e86607130289083fd249cda47374cf7d041cb6fe8
MD5 c5784815748b641749bf7d5215974349
BLAKE2b-256 38cb9ef42203abb69b87b76abf2ff257e3947c6f5416aaa6b5e3e381690546fe

See more details on using hashes here.

File details

Details for the file workflowlite-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: workflowlite-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for workflowlite-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e50dfc3104bba965375eda9f5ca4b3432436c0f4759d98b5ff3e9418a0234131
MD5 41b24a87bfa215652f4d619223f052ee
BLAKE2b-256 d9375c733ff35085cddc151d0a3eb359661d0973afe7897d2efb820cd14ba9f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page