Skip to content

Commit

Permalink
Update way to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kmagusiak committed Dec 29, 2023
1 parent a93f0e1 commit 3685091
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand All @@ -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`
Expand Down
6 changes: 3 additions & 3 deletions alphaconf/inject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand All @@ -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

0 comments on commit 3685091

Please sign in to comment.