Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alphaconf-0.1.dev1.tar.gz (14.0 kB view hashes)

Uploaded Source

Built Distribution

alphaconf-0.1.dev1-py3-none-any.whl (11.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page