Skip to main content

Extend click functionnalities by allowing parameters to be passed in a config file

Project description

Dclick

https://img.shields.io/pypi/v/dclick.svg https://circleci.com/gh/AnOtterGithubUser/double_click.svg?style=shield

Extend click functionnalities by allowing parameters to be passed in a config file.

  • Free software: BSD license

Features

  • Implement a new decorator ‘command_with_config’ which enables to pass default values for click options in a config file

  • Performs the same checks as click regarding values passed in config file (ex: check if path exists)

  • Seamless integration with click, just replace click.command with dclick.command_with_config

With click you would have to pass a default value directly in the code

from click import command
from click import option

@command()
@option('-n', '--n-epochs', type=int, default=5, help='Number of epochs to train the model')
def train(n_epochs):
    run_training_for(n_epochs)

if __name__ == '__main__':
    train()

However, if you want to run this code with different parameters you would have to edit the code each time or pass them in the command line. Both these solutions are not satisfying for automation and versioning. Imagine that you want to run your code inside a docker without the possibility to use the command line, like you are working with a managed platform on the cloud. With dclick you just have to change one line:

from dclick import command_with_config
from click import option

@command_with_config('path_to_config.json')
@option('-n', '--n-epochs', type=int)
def train(n_epochs):
    run_training_for(n_epochs):

if __name__ == '__main__':
    train()

Just be careful that the name in the config matches the name of the option. dclick takes care of the rest. You can pass a config as json, yaml or txt. Json and yaml are preferred.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2020-06-23)

  • First release on PyPI.

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

dclick-0.1.3.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

dclick-0.1.3-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file dclick-0.1.3.tar.gz.

File metadata

  • Download URL: dclick-0.1.3.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.8.0 tqdm/4.54.0 CPython/3.8.3

File hashes

Hashes for dclick-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d9cc6ddd7c6ab7f327a46247c72e71d11e766c0a7bec74815522b6914634df23
MD5 9a797688149409831d580554916a3253
BLAKE2b-256 a0f6dd63c8ee50c50a580d53f6fbbc8f8795b5c1ce6721d4eabcfbc56feaece1

See more details on using hashes here.

File details

Details for the file dclick-0.1.3-py2.py3-none-any.whl.

File metadata

  • Download URL: dclick-0.1.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.8.0 tqdm/4.54.0 CPython/3.8.3

File hashes

Hashes for dclick-0.1.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 542eea14b941cea5b0b70bd2a940a943a1adf4376fdd5eac2f9efce346279d1d
MD5 74afc627285bb0fbebd15199358cf222
BLAKE2b-256 38199e2f6fae0bd51b6520d5251e9b80c17043ac3cfd5c22c153991f9b8201b6

See more details on using hashes here.

Supported by

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