Lightweight workflow orchestration
Project description
Workflow Orchestration
The Lightweight Workflow Orchestration with fewer dependencies the was created
for easy to make a simple metadata driven data workflow. It can use for data operator
by a .yaml template.
[!WARNING] This package provide only orchestration workload. That mean you should not use the workflow stage to process any large volume data which use a lot of compute resource :cold_sweat:.
In my opinion, I think it should not create duplicate workflow codes if I can write with dynamic input parameters on the one template workflow that just change the input parameters per use-case instead. This way I can handle a lot of logical workflows in our orgs with only metadata configuration. It called Metadata Driven Data Workflow.
:pushpin: Rules of This Workflow engine:
- The Minimum frequency unit of scheduling is 1 minute :warning:
- Can not re-run only failed stage and its pending downstream :rotating_light:
- All parallel tasks inside workflow engine use Multi-Threading (Python 3.13 unlock GIL :unlock:)
:memo: Workflow Diagrams:
This diagram show where is this application run on the production infrastructure. You will see that this application do only running code with stress-less which mean you should to set the data layer separate this core program before run this application.
flowchart LR
subgraph Interface
A((User))
subgraph Docker Container
G@{ shape: rounded, label: "Observe<br>Application" }
end
end
A --->|action| B(Workflow<br>Application)
B ---> |response| A
B -..-> |response| G
G -..-> |request| B
subgraph Docker Container
B
end
subgraph Data Context
D@{ shape: processes, label: "Logs" }
E@{ shape: lin-cyl, label: "Metadata" }
end
subgraph Git Context
F@{ shape: tag-rect, label: "YAML<br>files" }
end
B --->|disable| F
F --->|read| B
B --->|write| E
E --->|read| B
B --->|write| D
D -.->|read| G
E -.->|read| G
[!NOTE] Disclaimer: I inspire the dynamic statement from the GitHub Action with
.ymlfiles and all configs file from several data orchestration framework tools from my experience on Data Engineer. :grimacing:Other workflow tools that I interest on them and pick some interested feature implement to this package:
:round_pushpin: Installation
This project need ddeutil and ddeutil-io extension namespace packages.
If you want to install this package with application add-ons, you should add
app in installation;
| Use-case | Install Optional | Support |
|---|---|---|
| Python | ddeutil-workflow |
:heavy_check_mark: |
| FastAPI Server | ddeutil-workflow[api] |
:heavy_check_mark: |
:beers: Usage
This is examples that use workflow file for running common Data Engineering use-case.
[!IMPORTANT] I recommend you to use the
hookstage for all actions that you want to do with workflow activity that you want to orchestrate. Because it is able to dynamic an input argument with the same hook function that make you use less time to maintenance your data workflows.
run-py-local:
# Validate model that use to parsing exists for template file
type: Workflow
on:
# If workflow deploy to schedule, it will run every 5 minutes
# with Asia/Bangkok timezone.
- cronjob: '*/5 * * * *'
timezone: "Asia/Bangkok"
params:
# Incoming execution parameters will validate with this type. It allows
# to set default value or templating.
source-extract: str
run-date: datetime
jobs:
getting-api-data:
stages:
- name: "Retrieve API Data"
id: retrieve-api
uses: tasks/get-api-with-oauth-to-s3@requests
with:
# Arguments of source data that want to retrieve.
method: post
url: https://finances/open-data/currency-pairs/
body:
resource: ${{ params.source-extract }}
# You can use filtering like Jinja template but this
# package does not use it.
filter: ${{ params.run-date | fmt(fmt='%Y%m%d') }}
auth:
type: bearer
keys: ${API_ACCESS_REFRESH_TOKEN}
# Arguments of target data that want to land.
writing_mode: flatten
aws_s3_path: my-data/open-data/${{ params.source-extract }}
# This Authentication code should implement with your custom hook
# function. The template allow you to use environment variable.
aws_access_client_id: ${AWS_ACCESS_CLIENT_ID}
aws_access_client_secret: ${AWS_ACCESS_CLIENT_SECRET}
The above workflow template is main executor pipeline that you want to do. If you
want to schedule this workflow, you want to dynamic its parameters change base on
execution time such as run-date should change base on that workflow running date.
So, this package provide the Schedule template for this action.
schedule-run-local-wf:
# Validate model that use to parsing exists for template file
type: Schedule
workflows:
# Map existing workflow that want to deploy with scheduler application.
# It allows you to pass release parameter that dynamic change depend on the
# current context of this scheduler application releasing that time.
- name: run-py-local
params:
source-extract: "USD-THB"
asat-dt: "${{ release.logical_date }}"
:cookie: Configuration
The main configuration that use to dynamic changing with your objective of this application. If any configuration values do not set yet, it will use default value and do not raise any error to you.
[!IMPORTANT] The config value that you will set on the environment should combine with prefix, component, and name which is
WORKFLOW_{component}_{name}(Upper case).
| Name | Component | Default | Description |
|---|---|---|---|
| ROOT_PATH | Core | . |
The root path of the workflow application. |
| REGISTRY | Core | . |
List of importable string for the hook stage. |
| REGISTRY_FILTER | Core | ddeutil.workflow.templates |
List of importable string for the filter template. |
| CONF_PATH | Core | conf |
The config path that keep all template .yaml files. |
| TIMEZONE | Core | Asia/Bangkok |
A Timezone string value that will pass to ZoneInfo object. |
| STAGE_DEFAULT_ID | Core | true |
A flag that enable default stage ID that use for catch an execution output. |
| STAGE_RAISE_ERROR | Core | false |
A flag that all stage raise StageException from stage execution. |
| JOB_DEFAULT_ID | Core | false |
A flag that enable default job ID that use for catch an execution output. The ID that use will be sequence number. |
| JOB_RAISE_ERROR | Core | true |
A flag that all job raise JobException from job strategy execution. |
| MAX_NUM_POKING | Core | 4 |
. |
| MAX_JOB_PARALLEL | Core | 2 |
The maximum job number that able to run parallel in workflow executor. |
| MAX_JOB_EXEC_TIMEOUT | Core | 600 |
|
| MAX_CRON_PER_WORKFLOW | Core | 5 |
|
| MAX_QUEUE_COMPLETE_HIST | Core | 16 |
|
| GENERATE_ID_SIMPLE_MODE | Core | true |
A flog that enable generating ID with md5 algorithm. |
| PATH | Log | ./logs |
The log path of the workflow saving log. |
| DEBUG_MODE | Log | true |
A flag that enable logging with debug level mode. |
| ENABLE_WRITE | Log | true |
A flag that enable logging object saving log to its destination. |
| MAX_PROCESS | App | 2 |
The maximum process worker number that run in scheduler app module. |
| MAX_SCHEDULE_PER_PROCESS | App | 100 |
A schedule per process that run parallel. |
| STOP_BOUNDARY_DELTA | App | '{"minutes": 5, "seconds": 20}' |
A time delta value that use to stop scheduler app in json string format. |
API Application:
| Environment | Component | Default | Description |
|---|---|---|---|
| ENABLE_ROUTE_WORKFLOW | API | true |
A flag that enable workflow route to manage execute manually and workflow logging. |
| ENABLE_ROUTE_SCHEDULE | API | true |
A flag that enable run scheduler. |
:rocket: Deployment
This package able to run as an application service for receive manual trigger from the master node via RestAPI or use to be Scheduler background service like crontab job but via Python API.
API Server
(venv) $ uvicorn src.ddeutil.workflow.api:app \
--host 127.0.0.1 \
--port 80 \
--no-access-log
[!NOTE] If this package already deploy, it is able to use multiprocess;
uvicorn ddeutil.workflow.api:app --host 127.0.0.1 --port 80 --workers 4
Docker Container
Create Docker image;
$ docker build -t ddeutil-workflow:latest -f .container/Dockerfile .
Run the above Docker image;
$ docker run -i ddeutil-workflow:latest
:speech_balloon: Contribute
I do not think this project will go around the world because it has specific propose, and you can create by your coding without this project dependency for long term solution. So, on this time, you can open the GitHub issue on this project :raised_hands: for fix bug or request new feature if you want it.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ddeutil_workflow-0.0.29.tar.gz.
File metadata
- Download URL: ddeutil_workflow-0.0.29.tar.gz
- Upload date:
- Size: 83.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5249662546bdffa1eca7318780d9fa5b400967608ca9d1d9bc329ad672ac4d47
|
|
| MD5 |
eb067e72c109d5218a5f18c65488110d
|
|
| BLAKE2b-256 |
f629ed371225638a0fa937820a0adf35a2365f9ce4a80d19b315857c59fa93a7
|
Provenance
The following attestation bundles were made for ddeutil_workflow-0.0.29.tar.gz:
Publisher:
publish.yml on ddeutils/ddeutil-workflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ddeutil_workflow-0.0.29.tar.gz -
Subject digest:
5249662546bdffa1eca7318780d9fa5b400967608ca9d1d9bc329ad672ac4d47 - Sigstore transparency entry: 172304170
- Sigstore integration time:
-
Permalink:
ddeutils/ddeutil-workflow@8ce0bb0f4f3e68a3f4d9db88af01bea74bdb7525 -
Branch / Tag:
refs/tags/v0.0.29 - Owner: https://github.com/ddeutils
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ce0bb0f4f3e68a3f4d9db88af01bea74bdb7525 -
Trigger Event:
release
-
Statement type:
File details
Details for the file ddeutil_workflow-0.0.29-py3-none-any.whl.
File metadata
- Download URL: ddeutil_workflow-0.0.29-py3-none-any.whl
- Upload date:
- Size: 70.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1df3c81ce1edab74eb60569221818866048cc24761c574afd0b35065460210d9
|
|
| MD5 |
24d8d7ab8ebea9740f9af740429f25ea
|
|
| BLAKE2b-256 |
da98b7662126c03b4465520decd4f29370a177aac1844df9544a14916982f8ff
|
Provenance
The following attestation bundles were made for ddeutil_workflow-0.0.29-py3-none-any.whl:
Publisher:
publish.yml on ddeutils/ddeutil-workflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ddeutil_workflow-0.0.29-py3-none-any.whl -
Subject digest:
1df3c81ce1edab74eb60569221818866048cc24761c574afd0b35065460210d9 - Sigstore transparency entry: 172304171
- Sigstore integration time:
-
Permalink:
ddeutils/ddeutil-workflow@8ce0bb0f4f3e68a3f4d9db88af01bea74bdb7525 -
Branch / Tag:
refs/tags/v0.0.29 - Owner: https://github.com/ddeutils
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8ce0bb0f4f3e68a3f4d9db88af01bea74bdb7525 -
Trigger Event:
release
-
Statement type: