Skip to main content

Configurable ML in Python

Project description

Configurable ML

python Coverage Status PyPI version PyPI - Downloads

Python utilities for easily configurable machine learning.

This project utilizes the excellent tutorial How to Publish an Open-Source Python Package to PyPI

Usage

from pyconfigurableml.entry import run

def main(config, log):
  # TODO: put your logic here.
  pass

if __name__ == '__main__':
  # The main function will be called with appropriate configuration
  # object and logger.
  run(main, __file__)

# Alternative approach. Will only load configuration + run main if
# __name__ == '__main__'.
run(main, __file__, __name__)

You may also use this library to configure a set of unit tests. If you're using PyTest,

from pyconfigurableml.entry import run_no_parse_args

def custom_setup_logic(config, log):
  # TODO: put your logic here.
  pass

def setup_module(module):
  # You probably don't want to attempt to parse command line arguments
  # inside unit tests.
  run_no_parse_args(custom_setup_logic, __file__)

Configuring this library

In addition to using pyconfigurableml to parse and inject configuration into your main method, you may also configure the library itself by adding some information under a pyconfigurableml field in your config file.

First, to enable these extras, install them:

pip install pyconfigurableml[azure,munch]

Then, add subfields following the example below.

# You may insert your other configuration here as usual.

# This section is for configuration specific to this library.
pyconfigurableml:

  azure:
    # Replace URLs to Azure Key Vault secrets with the secret values. The code
    # must be running in an environment with access to those key vaults.
    resolve_secret_identifiers: True

    # (Optional) Azure Active Directory tenant ID to use when initializing a
    # "default Azure credential" object.
    tenant: 2b9d773f-f2b1-43e7-8a53-bbe28bbb0c6b

  # Ensure files downloaded from the configured URLs exist at these paths
  # (relative to working directory). This library does not (yet) handle
  # authenticating against files stored in enterprise storage accounts (e.g.,
  # Azure blob storage).
  files:
    .data/resnet.tar.gz: https://github.com/onnx/models/raw/master/vision/classification/resnet/model/resnet18-v2-7.tar.gz
    .data/labels.txt: https://raw.githubusercontent.com/onnx/models/master/vision/classification/synset.txt

  # Dictionary mapping logger names to minimum levels. This is convenient for
  # suppressing overly verbose logs from consumed libraries.
  logging:
    azure.core.pipeline.policies.http_logging_policy: WARN

  # If this flag is set to true, the library will convert the configuration
  # object into a "JavaScript-style" object, i.e. a['b'] may be accessed via
  # a.b.
  munch: True

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

pyconfigurableml-0.5.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

pyconfigurableml-0.5.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pyconfigurableml-0.5.0.tar.gz.

File metadata

  • Download URL: pyconfigurableml-0.5.0.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for pyconfigurableml-0.5.0.tar.gz
Algorithm Hash digest
SHA256 a1b9ddfc1c8dab86d0d166d2a5912068bdd5ec14a27e07a21287eaa6f2ee1ec6
MD5 8a461487836c626941ff857597331ce3
BLAKE2b-256 8d9632a69dc5ae58979e6039c1c3d8dbd680a02d4912484e0c5fffbe2af9350c

See more details on using hashes here.

File details

Details for the file pyconfigurableml-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pyconfigurableml-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.6

File hashes

Hashes for pyconfigurableml-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8aba974f523ddeead0c01c909d39674aadffde72206128d4191191f59416a9ec
MD5 a92aba6d41614e7994cc28ed5508eac1
BLAKE2b-256 f137e734234ed888c9d06618a4bb0e4efafb90bba46d3c1fced620364c2083f3

See more details on using hashes here.

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