From 36850910c76b59326da1a5fedfd9445e608fcb77 Mon Sep 17 00:00:00 2001 From: Krzysztof Magusiak Date: Fri, 29 Dec 2023 21:54:08 +0100 Subject: [PATCH] Update way to 1.0 --- .github/workflows/python-publish.yaml | 2 +- README.md | 19 +++++++++++-------- alphaconf/inject.py | 6 +++--- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-publish.yaml b/.github/workflows/python-publish.yaml index fdcd2b6..edefb29 100644 --- a/.github/workflows/python-publish.yaml +++ b/.github/workflows/python-publish.yaml @@ -40,7 +40,7 @@ jobs: with: user: __token__ password: ${{ secrets.PYPI_TEST_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ + repository-url: https://test.pypi.org/legacy/ - name: Publish package if: "startsWith(github.ref, 'refs/tags')" uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/README.md b/README.md index 8fef71e..e83042b 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,6 @@ easily. The configuration is based on [OmegaConf]. Optionally, loading from toml or using [pydantic] is possible. -To run multiple related tasks, there is an integration with -[invoke](https://www.pyinvoke.org). -If you need something more complex, like running multiple instances of the -script, take a look at [hydra-core](https://hydra.cc) or use another script -to launch multiple instances. - ## Demo and application To run an application, you need... @@ -110,7 +104,7 @@ class MyConf(pydantic.BaseModel): alphaconf.setup_configuration(MyConf, prefix='a') # read the value alphaconf.get('a', MyConf) -v = alphaconf.get(MyConf) # because it's registered as a type +v = alphaconf.get(MyConf) # shortcut, because it's registered as a type ``` ### Secrets @@ -147,7 +141,13 @@ def main(name: str=None, example=None): ### Invoke integration -Just add the lines below to parameterize invoke. +To run multiple related tasks, there is an integration with +[invoke](https://www.pyinvoke.org). +If you need something more complex, like running multiple instances of the +script, take a look at [hydra-core](https://hydra.cc) or use another script +to launch multiple instances. + +Just add the lines below to parameterize `invoke`. Note that the argument parsing to overwrite configuration will work only when the script is directly called. @@ -159,6 +159,9 @@ alphaconf.invoke.run(__name__, ns) ``` ## Way to 1.0 +- Make argument parsing separate from the core +- Compare `plumbum` and `invoke` for building scripts +- Secret handling and encryption - Run a specific function `alphaconf my.module.main`: find functions and inject args - Install completions for bash `alphaconf --install-autocompletion` diff --git a/alphaconf/inject.py b/alphaconf/inject.py index ffd8620..7c8e93d 100644 --- a/alphaconf/inject.py +++ b/alphaconf/inject.py @@ -33,7 +33,7 @@ def __call__(self, *a, **kw): def wrap(func) -> "ParamDefaultsFunction": if isinstance(func, ParamDefaultsFunction): return func - return functools.wraps(func)(ParamDefaultsFunction(func)) + return ParamDefaultsFunction(func) def getter( @@ -71,7 +71,7 @@ def do_inject(func): else: b = factory f.bind(name, b) - return f + return functools.wraps(func)(f) return do_inject @@ -87,6 +87,6 @@ def do_inject(func): if name in ignore: continue f.bind(name, getter(prefix + name, param=param)) - return f + return functools.wraps(func)(f) return do_inject