Write simple scripts leveraging omegaconf
Project description
Alphaconf
A small library to ease writing parameterized scripts. The goal is to execute a single script and be able to overwrite the parameters easily. The configuration is based on omegaconf.
To run multiple related tasks, there is an integration with invoke. If you need something more complex, like running multiple instances of the script, take a look at hydra-core or use another script to launch multiple instances.
Demo and application
(DEMO)[demo.ipynb]
To run an application, you need...
import alphaconf
# each module or application can declare the default configuration they need
# it will always be loaded first
alphaconf.setup_configuration("""
server:
url: http://default
user: ${oc.env:USER}
""")
def main():
log = logging.getLogger()
# get the DictConfig from the current application
log.info('app name:', alphaconf.configuration().application.name)
# shortcut to get an option as a dict, str, etc.
log.info('server.user:', alphaconf.get('server.user'))
if __name__ == '__main__':
# run the application
alphaconf.Application(
name='example',
version='0.1',
).run(main)
Invoke integration
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.
ns = Collection() # define the invoke configuration
import alphaconf.invoke
alphaconf.setup_configuration({'backup': 'all'})
alphaconf.invoke.invoke_application(__name__, ns)
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
File details
Details for the file alphaconf-0.1.dev1.tar.gz
.
File metadata
- Download URL: alphaconf-0.1.dev1.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 496766173108d78a99ef1d92619a9c7dec67e960fc724400e9e46b19f869ee24 |
|
MD5 | af6e77dd79c72005493a5a8d29c190fe |
|
BLAKE2b-256 | 81005d7c6254373e59694b2e41d69bc1f4c69779afc2b5dcbba06a9e2f5c27fe |
File details
Details for the file alphaconf-0.1.dev1-py3-none-any.whl
.
File metadata
- Download URL: alphaconf-0.1.dev1-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a65095ff05ccc7d03182fc84d4c0800ffd015252794954f22ad35fa1e94b094 |
|
MD5 | b7e635db4c1a185b68a4ad2ef565eadf |
|
BLAKE2b-256 | 55be84bb8f5afac9cc9844243fe02375666e6722bf95d4f4cb50136c064577d1 |