A pipen cli plugin to check requirements for processes of a pipeline
Project description
pipen-cli-require
Checking the requirements for processes of a 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:
- name: pipen
message: Run `pip install -U pipen` to install
check: |
{{proc.lang}} -c "import pipen"
- name: liquidpy
message: Run `pip install -U liquidpy` to install
check: |
{{proc.lang}} -c "import liquid"
- name: nonexist
message: Run `pip install -U nonexist` to install
check: |
{{proc.lang}} -c "import nonexist"
- name: optional
if: {{proc.envs.require_optional}}
check:
{{proc.lang}} -c "import optional"
"""
input = "a"
output = "outfile:file:out.txt"
envs = {"require_optional": False}
lang = "python"
# Setup the pipeline
# Must be outside __main__
# Or define a function to return the pipeline
pipeline = Pipen(...)
if __name__ == '__main__':
# Pipeline must be executed with __main__
pipeline.run()
Checking the requirements via the CLI
> pipen require -v -n 2 tests/example_pipeline.py:example_pipeline
Checking requirements for pipeline: EXAMPLE_PIPELINE
│
├── 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'
│ │
│ ├── ❎ nonexist2_nomsg
│ │ └── Traceback (most recent call last):
│ │ File "<string>", line 1, in <module>
│ │ ModuleNotFoundError: No module named 'nonexist'
│ │
│ └── ⏩ optional (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
:
from pipen_args import args as _
See also tests/pipen_args_pipeline.py
Then specify the path of the python to use:
pipen require tests/example_pipeline.py:example_pipeline --P1.lang /path/to/another/python
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
Close
Hashes for pipen_cli_require-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc16b40e20ce739e40ea38b13dbadc72af7e749329bf5f56cb6eaf2585b3a910 |
|
MD5 | 44d903720e05a7e2808935d5ad86792e |
|
BLAKE2b-256 | d500a388a6ddf02db2d89ac7e5c9808af969eb60d35168aa20d09fcfa0845436 |