A simple pipeline runner for Python tasks
Project description
logycon-pipeline
A simple pipeline runner for Python tasks that allows you to define and execute a series of tasks in sequence.
Installation
pip install logycon-pipeline
Usage
- Create a pipeline specification file (e.g.,
pipeline.json):
{
"name": "my-pipeline",
"version": "1.0.0",
"description": "My awesome pipeline",
"tasks": [
{
"name": "task1",
"script": "./scripts/task1.py",
"env": {
"CUSTOM_VAR": "value"
}
},
{
"name": "task2",
"script": "./scripts/task2.py"
}
]
}
- Use the pipeline in your code:
from logycon_pipeline import Pipeline
async def main():
pipeline = Pipeline('./pipeline.json')
try:
results = await pipeline.run()
print('Pipeline completed successfully:', results)
except Exception as error:
print('Pipeline failed:', error)
if __name__ == '__main__':
import asyncio
asyncio.run(main())
Task Scripts
Each task script should be a Python script that:
- Performs the required operations
- Outputs its result as a JSON string on the last line of stdout
- Returns 0 on success, non-zero on failure
Example task script:
# scripts/task1.py
import json
import sys
def main():
# Do something
result = {"status": "success", "data": "some data"}
print(json.dumps(result))
return 0
if __name__ == '__main__':
sys.exit(main())
API
Pipeline
The main class for running pipelines.
Constructor
def __init__(self, spec_path: str)
Creates a new pipeline instance from a specification file.
Methods
async def run() -> List[TaskResult]
Runs all tasks in the pipeline and returns a list of results.
Types
class Task:
name: str
script: str
env: Optional[Dict[str, str]]
class PipelineSpec:
name: str
version: str
description: str
tasks: List[Task]
class TaskResult:
task: str
success: bool
data: Optional[Any]
error: Optional[str]
License
MIT
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 logycon_pipeline-0.1.0.tar.gz.
File metadata
- Download URL: logycon_pipeline-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7f67008375a255a5cd5e6bb506183774b6b892c824d15549f1552c3f0d34674
|
|
| MD5 |
b097cc791abf2da724ebce3a7d73767b
|
|
| BLAKE2b-256 |
9198fd016fa66a956593433628f45196a78758b33cfbf320e2bbb5ec9eb9f12c
|
File details
Details for the file logycon_pipeline-0.1.0-py3-none-any.whl.
File metadata
- Download URL: logycon_pipeline-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02e5f9b8e59e59f3828dd153f14f16ea422efd89e445de54a189404d1045741f
|
|
| MD5 |
487bf5f675dbf68794c37a0f228e930d
|
|
| BLAKE2b-256 |
95e58bac00579940b69b7cb8d8c2552e91eda002a559e08430976316304565ef
|