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.11.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.11-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: workflow_builder-0.11.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.11.tar.gz
Algorithm Hash digest
SHA256 7fa281b5915f90abbd4ca2e14e0d2ed82ccf54ec1f80f4ac492f3f0ff7d4dcfa
MD5 75731b9b55e123726f95196ce07237ec
BLAKE2b-256 e4f32aeefdc3d6a8bd4dcdeadfd5b4a08c0128eff0cd2d42cd5f3b2980d98c59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for workflow_builder-0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 e0b4f3f1ac279a4fb6aeed37c072e14c1548e3573c7c803c1bf9ff1299f53958
MD5 973891f865fcb50d85da07593cda9993
BLAKE2b-256 019de418ad9d1e2ea37e71f84d1cedc2636f1481094e4af69655b9997e49a16c

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