We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There were also a few requests for this one. Any takers?
The text was updated successfully, but these errors were encountered:
Here is a contrived example of how to use clickify_parameters. You need a main application where you create a command group e.g.
https://github.com/ratt-ru/pfb-imaging/blob/main/pfb/workers/main.py
Then import the cli inside your app like so
cli
https://github.com/ratt-ru/pfb-imaging/blob/v0.0.5-dev/pfb/workers/init.py
You can define the arguments for the function in the function signature or use a separate yaml config in combination with something like the following
https://github.com/ratt-ru/pfb-imaging/blob/v0.0.5-dev/pfb/parser/schemas.py
where your configs are defined in the same folder e.g.
https://github.com/ratt-ru/pfb-imaging/blob/v0.0.5-dev/pfb/parser/init.yaml
But maybe not your simplest example!
Sorry, something went wrong.
Group Nu's take on the 'hello' app using clickify_parameters:
contents of apps/hello.py
apps/hello.py
#! /usr/bin/python import click from pathlib import Path from scabha.schema_utils import clickify_parameters from omegaconf import OmegaConf recipe = Path(__file__).parent.parent / "recipes/hello.yml" schemas = OmegaConf.load(recipe) @click.command("hello") @clickify_parameters(schemas.cabs.get("hello")) def main(**kw): print(recipe) hello(**kw) def hello(name): greeting = f"Hello {name}!" click.echo(greeting) return greeting
contents of recipes/hello.yml:
recipes/hello.yml
opts: log: dir: logs/log-{config.run.datetime} name: log-{info.fqname} nest: 2 symlink: log cabs: hello: # cab info: this runs the clickified hello app command: hello inputs: name: dtype: str required: true
and a pytest unit test:
from apps.hello import hello def test_hello(): assert hello("test") == f"Hello test!"
We can then just run hello --name Michael for example to get the program to run, using the following line in pyproject.toml:
hello --name Michael
pyproject.toml
[tool.poetry.scripts] hello = "nu.apps.hello:main"
Very clean and concise. Thanks @astronomike
No branches or pull requests
There were also a few requests for this one. Any takers?
The text was updated successfully, but these errors were encountered: