# pipen-args
Command line argument parser for [pipen][1]
## Usage
```python
from pipen import Proc, Pipen
class Process(Proc):
"""My process
Input:
a: Input data
"""
input = 'a'
input_data = range(10)
script = 'echo {{in.a}}'
Pipen().set_start(Process).run()
```
```shell
$ python example.py --help
Usage: test.py [-h | -h+] [options]
Undescribed process.
Use `@configfile` to load default values for the options.
Pipeline Options:
--name NAME The name for the pipeline, will affect the default workdir and
outdir. [default: pipen-0]
--profile PROFILE The default profile from the configuration to run the pipeline.
This profile will be used unless a profile is specified in the
process or in the .run method of pipen. You can check the
available profiles by running `pipen profile`
--outdir OUTDIR The output directory of the pipeline [default: ./<name>-output]
--forks FORKS How many jobs to run simultaneously by the scheduler
--scheduler SCHEDULER
The scheduler to run the jobs
Namespace <in>:
--in.a A [A ...] Input data
Optional Arguments:
-h, --help, -h+, --help+
show help message (with + to show more options) and exit
```
See more examples in `tests/pipelines/` folder.
## Plugin options
- `args_hide`: (process level) Hide the arguments in the help message. Default: `False`
- `args_group`: (pipeline level) The group name for the arguments. Default: `pipeline options`
- `args_flatten`: (pipeline level) Flatten the arguments in the help message when there is only one process in the pipeline. Default: `auto` (flatten if single process, otherwise not)
- `args_dump`: (pipeline level) Whether to dump the arguments to `<outdir>/args.toml` file. Default: `False`.
> [!NOTE]
> Only `args_dump` can be passed from the command line or a configuration file.
> Other options can only be set in the pipeline class, passed to the `Pipen` construct.
> Because they are used to construct the argument parser and we don't
> know the value of these options before the argument parser is constructed.
## Metadata for Proc envs items
The metadata in the docstring of env items determines how the arguments are defined.
```python
class Process(Proc):
"""My process
# other docstring sections
Envs:
a (<metadata>): ...
"""
```
The metadata could be key-value pairs separated by `;`. The separator `:` or `=` is used to
separate the key and value. The value is optional. If the value is not specified, it
will be set to `True`. The keys are valid arguments of `argx.ArgumentParser.add_argument`, except that `hidden` will be interpreted as `show=False` in `argx.ArgumentParser.add_argument`. If the value of `choices` is not specified, the subkeys of the env item will be used as the choices.
[1]: https://github.com/pwwang/pipen
Raw data
{
"_id": null,
"home_page": "https://github.com/pwwang/pipen-args",
"name": "pipen-args",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "pwwang",
"author_email": "pwwang@pwwang.com",
"download_url": "https://files.pythonhosted.org/packages/89/02/987d5da8a02a34d2941e014d87b2074badd9451f17e57c497f062aa0a650/pipen_args-0.16.4.tar.gz",
"platform": null,
"description": "# pipen-args\n\nCommand line argument parser for [pipen][1]\n\n## Usage\n\n```python\nfrom pipen import Proc, Pipen\n\n\nclass Process(Proc):\n \"\"\"My process\n\n Input:\n a: Input data\n \"\"\"\n input = 'a'\n input_data = range(10)\n script = 'echo {{in.a}}'\n\nPipen().set_start(Process).run()\n```\n\n```shell\n$ python example.py --help\nUsage: test.py [-h | -h+] [options]\n\nUndescribed process.\nUse `@configfile` to load default values for the options.\n\nPipeline Options:\n --name NAME The name for the pipeline, will affect the default workdir and\n outdir. [default: pipen-0]\n --profile PROFILE The default profile from the configuration to run the pipeline.\n This profile will be used unless a profile is specified in the\n process or in the .run method of pipen. You can check the\n available profiles by running `pipen profile`\n --outdir OUTDIR The output directory of the pipeline [default: ./<name>-output]\n --forks FORKS How many jobs to run simultaneously by the scheduler\n --scheduler SCHEDULER\n The scheduler to run the jobs\n\nNamespace <in>:\n --in.a A [A ...] Input data\n\nOptional Arguments:\n -h, --help, -h+, --help+\n show help message (with + to show more options) and exit\n```\n\nSee more examples in `tests/pipelines/` folder.\n\n## Plugin options\n\n- `args_hide`: (process level) Hide the arguments in the help message. Default: `False`\n- `args_group`: (pipeline level) The group name for the arguments. Default: `pipeline options`\n- `args_flatten`: (pipeline level) Flatten the arguments in the help message when there is only one process in the pipeline. Default: `auto` (flatten if single process, otherwise not)\n- `args_dump`: (pipeline level) Whether to dump the arguments to `<outdir>/args.toml` file. Default: `False`.\n\n> [!NOTE]\n> Only `args_dump` can be passed from the command line or a configuration file.\n> Other options can only be set in the pipeline class, passed to the `Pipen` construct.\n> Because they are used to construct the argument parser and we don't\n> know the value of these options before the argument parser is constructed.\n\n## Metadata for Proc envs items\n\nThe metadata in the docstring of env items determines how the arguments are defined.\n\n```python\nclass Process(Proc):\n \"\"\"My process\n\n # other docstring sections\n\n Envs:\n a (<metadata>): ...\n \"\"\"\n```\n\nThe metadata could be key-value pairs separated by `;`. The separator `:` or `=` is used to\nseparate the key and value. The value is optional. If the value is not specified, it\nwill be set to `True`. The keys are valid arguments of `argx.ArgumentParser.add_argument`, except that `hidden` will be interpreted as `show=False` in `argx.ArgumentParser.add_argument`. If the value of `choices` is not specified, the subkeys of the env item will be used as the choices.\n\n[1]: https://github.com/pwwang/pipen\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Command-line argument parser for pipen.",
"version": "0.16.4",
"project_urls": {
"Homepage": "https://github.com/pwwang/pipen-args",
"Repository": "https://github.com/pwwang/pipen-args"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "50168d3771c2c25eb2172ba14eecb3c3c84d4b1663c4de904f4f7b1e74d19869",
"md5": "12a0212c9b2ebd9e220c5a38ca386ed2",
"sha256": "d3fc3bcac037098bfdb05d6eafa244508f15e577c433e52ee06c78391a973b85"
},
"downloads": -1,
"filename": "pipen_args-0.16.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "12a0212c9b2ebd9e220c5a38ca386ed2",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 14969,
"upload_time": "2025-02-15T04:09:06",
"upload_time_iso_8601": "2025-02-15T04:09:06.062666Z",
"url": "https://files.pythonhosted.org/packages/50/16/8d3771c2c25eb2172ba14eecb3c3c84d4b1663c4de904f4f7b1e74d19869/pipen_args-0.16.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8902987d5da8a02a34d2941e014d87b2074badd9451f17e57c497f062aa0a650",
"md5": "363b652b323429242a35ed46418153c6",
"sha256": "d42821cd53adb66fcd452e8fd75da84d6db94b6a582addb6abdde4b89cd665a0"
},
"downloads": -1,
"filename": "pipen_args-0.16.4.tar.gz",
"has_sig": false,
"md5_digest": "363b652b323429242a35ed46418153c6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 13536,
"upload_time": "2025-02-15T04:09:07",
"upload_time_iso_8601": "2025-02-15T04:09:07.863188Z",
"url": "https://files.pythonhosted.org/packages/89/02/987d5da8a02a34d2941e014d87b2074badd9451f17e57c497f062aa0a650/pipen_args-0.16.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-15 04:09:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pwwang",
"github_project": "pipen-args",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pipen-args"
}