Skip to main content

PIRUPY : A PIpeline RUnner for PYthon

Latest version Workflow status Download status

A set of annotations to define a set of 'jobs' regrouped into a sequence of 'stages', forming a 'pipeline'. Pipelines and jobs have hooks to perform pre-processings and post-processings.

The principle for ordering calls is to follows the order of appearance. As such, inside a stage, the jobs will be called following the same order than how they appear in the application. Same for the order of calling 'before all' hooks, 'before each' hooks, 'after each' hooks, and 'after all' hooks.

PIRUPY was inspired by :

  • gitlab-ci pipelines for the model ;
  • JUnit for the annotation-based system ;
  • and my distaste for yaml.

How to use

Logging

PIRUPY use a logger named 'pipeline_runner'

Requirements on annotaded functions

Jobs and hooks functions are provided with a keyword argument env, a dictionnary containing resources to be used to perform the job and the hooks.

The env dictionnary is returned by the pipeline function. The pipeline function usually create the dictionnary, whereas hooks functions add ('before all' and 'before each' hooks) or remove ('after all' and 'after each' hooks) ressources into the dictionnary.

Each jobs execution (that includes the hooks 'before_each' and 'after_each') are provided with a clone of this environment, meaning that a jobs cannot interfere (adding or substracting keys) with the environment content of the next jobs. Of course, any mutable object in the environment can be changed by a job for the next.

Typical use

    #... skipping imports, logging config, etc...

    @pipeline(stages=("first_stage","second_stage","third_stage"))
    def performMySuiteOfTests(env:dict = {}):
        logging.info("Start of pipeline -- init")
        logging.debug(env)
        return env

    @job(stage="first_stage")
    def B(*, env:dict = {}):
        logging.info("performing... B")
        pass

    @job(stage="first_stage")
    def A(*, env:dict = {}):
        logging.info("performing... A")
        pass

    @job(stage="second_stage")
    def C(*, env:dict = {}):
        logging.info("performing... C")
        pass

    @job(stage="second_stage")
    def F(*, env:dict = {}):
        logging.info("performing... F")
        pass

    @job(stage="third_stage")
    def E(*, env:dict = {}):
        logging.info("performing... E")
        pass

    @job(stage="second_stage")
    def D(*, env:dict = {}):
        logging.info("performing... D")
        pass

    @job(stage="third_stage")
    def G(*, env:dict = {}):
        logging.info("performing... G")
        pass

    @job()
    def H(*, env:dict = {}): # performed at each stage
        logging.info("performing... H")
        pass

    @before_all
    def setup(*, env:dict = {}):
        logging.info("performing... setup")
        pass

    @after_all
    def teardown(*, env:dict = {}):
        logging.info("performing... teardown")
        pass

    @before_each(stage="first_stage")
    def enter_first_stage_job(*, env:dict = {}): # called only before performing each job of a given stage
        logging.info("performing... enter_first_stage_job")
        pass

    @after_each
    def exit_job(*, env:dict = {}): # called after each jobs has been called during any stage.
        logging.info("performing... exit_job")
        pass

    ### Ready to run
    if __name__ == "__main__":
        logging.warn("before pipeline")
        performMySuiteOfTests(env={'dir.current':'this/path', 'dir.basedir':'that/path'})
        logging.warn("after pipeline")

(c) 2022 David SPORN


PIRUPY is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PIRUPY is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with PIRUPY. If not, see https://www.gnu.org/licenses/. 


Release files for pirupy-by-sporniket 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pirupy-by-sporniket 0.0.3
File Size Uploaded
pirupy-by-sporniket-0.0.3.tar.gz 18.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pirupy-by-sporniket 0.0.3
File Interpreter ABI Platform
pirupy_by_sporniket-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 36.7 kB

Release files / pirupy-by-sporniket-0.0.3.tar.gz

Download URL pirupy-by-sporniket-0.0.3.tar.gz
Size 18.0 kB
Tags Source
SHA-256 checksum
How to use checksums
18cd4fb782e9528ed1f6829f09cf11bc1afe37f1e19b80725b9125f962f3e623
BLAKE2b-256 checksum
How to use checksums
3c291f0e358fd94970fccb6d7d461e2022e0e18b6afb89cc323d71c94ec2cfcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

Release files / pirupy_by_sporniket-0.0.3-py3-none-any.whl

Download URL pirupy_by_sporniket-0.0.3-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1cc7c17fd7b7a096c1c55f9a23be0185d7dd8f91f38bfc2791c2b40e6ec0d5f2
BLAKE2b-256 checksum
How to use checksums
f5b408b1602db1aaebf042828c5aebbc9d173160ddce2c7e5d5f6188aa3a76af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page