Skip to main content

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

  1. 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"
    }
  ]
}
  1. 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:

  1. Performs the required operations
  2. Outputs its result as a JSON string on the last line of stdout
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

logycon_pipeline-0.1.0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

logycon_pipeline-0.1.0-py3-none-any.whl (3.4 kB view details)

Uploaded Python 3

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

Hashes for logycon_pipeline-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a7f67008375a255a5cd5e6bb506183774b6b892c824d15549f1552c3f0d34674
MD5 b097cc791abf2da724ebce3a7d73767b
BLAKE2b-256 9198fd016fa66a956593433628f45196a78758b33cfbf320e2bbb5ec9eb9f12c

See more details on using hashes here.

File details

Details for the file logycon_pipeline-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for logycon_pipeline-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 02e5f9b8e59e59f3828dd153f14f16ea422efd89e445de54a189404d1045741f
MD5 487bf5f675dbf68794c37a0f228e930d
BLAKE2b-256 95e58bac00579940b69b7cb8d8c2552e91eda002a559e08430976316304565ef

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