Skip to main content

A tool for building and executing workflows

Project description

WorkflowBuilder

Introduction

WorkflowBuilder is a tool for building and executing workflows. It allows users to define configuration classes, task classes, and workflows to create complex workflows, which can be easily managed and executed.

Installation

Ensure you have Python 3.6+ installed, then install WorkflowBuilder via pip: pip install workflow_builder

Usage Example

Configuration Class

First, define a configuration class to store the configuration information needed by the workflow. Here we define a configuration class named ExampleConfiguration that contains a greeting field. python from workflow_builder import configclass, Configuration

Parameters specify aliases

@configclass('example', 'example_config') class ExampleConfiguration(Configuration): greeting: str

Task Classes

Next, define task classes. Each task class must inherit from the Task class and implement the preprocess and work methods.

ExampleTask1

ExampleTask1 is a specific task class that retrieves ExampleConfiguration from the workflow's configuration manager before execution and returns a dictionary containing the processing results in the work method. python class ExampleTask1(Task): def init(self, task_config: TaskConfig): task_config.name = '' # task_config.asynchronize = True self.config = None

def preprocess(self, workflow: Workflow):
    self.config = workflow.config_manager[ExampleConfiguration]

def work(self, workflow):
    return {
        'example_task1': self.config.greeting + ' World'
    }

ExampleTask

ExampleTask is another task class that receives output from ExampleTask1 in its work method and prints it. python class ExampleTask(Task): def init(self): ...

def preprocess(self, workflow: Workflow):
    ...

def work(self, example_task1):
    print(example_task1)

Workflow

Finally, add the task classes to the workflow and create and execute the pipeline. python tasks = [ ExampleTask1, ExampleTask ]

wf = Workflow(tasks)

Manually specify configs

workflow = Workflow(tasks, configs=configs)

Load toml from the current directory by default:

workflow = Workflow(tasks, configs_path='.')

pipeline = wf.create_pipeline()

Execute pipeline

pipeline()

Configuration File

By default, the workflow loads toml configuration files from the current directory. You can specify other paths using the configs_path parameter.

test.toml Example

[example] greeting = "Hello"

Running

Ensure the configuration file exists, then run the following command to execute the workflow: python your_script.py

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

workflow_builder-0.1.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

workflow_builder-0.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file workflow_builder-0.1.tar.gz.

File metadata

  • Download URL: workflow_builder-0.1.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.19

File hashes

Hashes for workflow_builder-0.1.tar.gz
Algorithm Hash digest
SHA256 bea2c36af9f8f7ac95e6adb00475564218ba70fa3aab5b49f85288107b896ef5
MD5 9a4d14af2a9973edebefc7c971e11e1b
BLAKE2b-256 cfa0d378ae7d937c32360460dd29fa852782529af5d43a1f6738e5382233417a

See more details on using hashes here.

File details

Details for the file workflow_builder-0.1-py3-none-any.whl.

File metadata

  • Download URL: workflow_builder-0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.19

File hashes

Hashes for workflow_builder-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa5fc8d0c8dd88284c85427b89568812eeb7b3b05cd2185c9b66de9cecbd1148
MD5 a160709d0e2c70ecace59ff70d3ef488
BLAKE2b-256 aabf0cce0ae844262fa879bd6c280083e1e384fb19594cc5fb845112bae40fce

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