Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a local or global configuration file to OpenQML #40

Merged
merged 4 commits into from
Sep 12, 2018

Conversation

josh146
Copy link
Member

@josh146 josh146 commented Sep 11, 2018

This pull request adds a simple configuration file to OpenQML. Changes include:

  1. the new Configuration class in configuration.py, to load, store, and save configuration information.
  2. on OpenQML initialisation __init__.py, certain directories are now scanned, and if a config.toml file is found, it is loaded up to be the default configuration. The three directories are:
    a. The current/script execution directory
    b. The directory under environment variable OPENQML_CONF
    c. The standard user configuration directory (i.e. ~/.config/openqml on linux, %APPDATA%\openqml on windows, etc.)
  3. the openqml.device loader now also accepts a Configuration object as a keyword argument. If not provided, the default_config determined in (2) is used. These are merged with the provided kwargs and used to load the device.

Two new modules are required: toml and appdirs. TOML was chosen as it is simpler than JSON or YAML (it is based on ini), and standardised (supports comments, nesting, etc.). The appdirs module allows easy determination of standard user configuration directories across all operating systems.

I've also added a default_config.toml file to the repository for reference. Since TOML allows nesting, you can set config options either (a) globally, (b) for all devices within a plugin, or (c) for only a specific device.


Note: it should be up to the OpenQML documentation, as well as all plugin documentation, to clearly set out the configurations allowed in the config file.

@josh146 josh146 added enhancement ✨ New feature or request interface 🔌 Classical machine-learning interfaces labels Sep 11, 2018
@josh146 josh146 changed the title Adds a local configuration file to OpenQML Adds a local or global configuration file to OpenQML Sep 11, 2018
Copy link
Member

@co9olguy co9olguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Any way we could add a test (which runs on a default config file) which makes sure the Configuration class and loading from config works as expected?

openqml/__init__.py Outdated Show resolved Hide resolved
default_config.toml Outdated Show resolved Hide resolved
openqml/configuration.py Show resolved Hide resolved
@josh146 josh146 merged commit 217f550 into new_user_interface Sep 12, 2018
@josh146 josh146 deleted the config_file branch September 12, 2018 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request interface 🔌 Classical machine-learning interfaces
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants