Skip to main content

A pipen cli plugin to check requirements for processes of a pipeline

Project description

pipen-cli-require

Checking the requirements for processes of a pipen pipeline

Install

pip install -U pipen-cli-require

Usage

Defining requirements of a process

# example_pipeline.py
from pipen import Pipen, Proc

class P1(Proc):
    """Process 1

    Requires:
        pipen: Run `pip install -U pipen` to install
          - check: |
            {{proc.lang}} -c "import pipen"
        liquidpy: Run `pip install -U liquidpy` to install
          - check: |
            {{proc.lang}} -c "import liquid"
        nonexist: Run `pip install -U nonexist` to install
          - check: |
            {{proc.lang}} -c "import nonexist"
        conditional:
          - if: {{envs.require_conditional}}
          - check:
            {{proc.lang}} -c "import optional"

    """
    input = "a"
    output = "outfile:file:out.txt"
    envs = {"require_conditional": False}
    lang = "python"

# Setup the pipeline
# Must be outside __main__
# Or define a function to return the pipeline
class Pipeline(Pipen):
    starts = P1


if __name__ == '__main__':
    # Pipeline must run with __main__
    Pipeline().run()

Parsing process requirements using API

from pipen_cli_require import parse_proc_requirements


def parse_proc_requirements(
    proc: Type[Proc]
) -> Tuple[OrderedDiot, OrderedDiot]:
    """Parse the requirements of a process

    Args:
        proc: The process class

    Returns:
        A tuple of two OrderedDiot's.
        The first one is the annotated sections by pipen_annotate
        The second one is the requirements. The key is the name of the
            requirement, the value is a dict with message, check and if_ keys.
    """

Checking the requirements via the CLI

> pipen require --verbose --ncores 2 -p example_pipeline.py:pipeline

Checking requirements for pipeline: PIPEN-0
│
└── P1: Process 1
    ├──  pipen
    ├──  liquidpy
    ├──  nonexist: Run `pip install -U nonexist` to install
       └── Traceback (most recent call last):
             File "<string>", line 1, in <module>
           ModuleNotFoundError: No module named 'nonexist'
        └──  conditional (skipped by if-statement)

Checking requirements with runtime arguments

For example, when I use a different python to run the pipeline:

Add this to the head of example_pipeline.py:

import pipen_args

See also tests/pipen_args_pipeline.py

Then specify the path of the python to use:

pipen require example_pipeline.py:pipeline --P1.lang /path/to/another/python

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

pipen_cli_require-1.0.2.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

pipen_cli_require-1.0.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file pipen_cli_require-1.0.2.tar.gz.

File metadata

  • Download URL: pipen_cli_require-1.0.2.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for pipen_cli_require-1.0.2.tar.gz
Algorithm Hash digest
SHA256 fffd44e0c4d627155ef85999970648678c8b678c7369f94f4f650143fae22b97
MD5 a9cf01df4e351e27f22566ac64fdff02
BLAKE2b-256 15ade6578c8adf3c02b045a7e271e67b6d9b382521f0aea63ad53aa05b50d8c1

See more details on using hashes here.

File details

Details for the file pipen_cli_require-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: pipen_cli_require-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for pipen_cli_require-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22f37689a6f44fe93c4625528ce22a8341f82841a3059b77bf98bc2f1bd384ce
MD5 33bd4425f3fc4cd236cc0576d59f0f79
BLAKE2b-256 b0fd4a926e913184f636767361df34ff4705179a492b0c239498d7f9506c9c89

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