Skip to content

Config file

Matthew Bourque edited this page Apr 10, 2018 · 7 revisions

In order to avoid hard coding commonly used data, or data that may be a security risk (such as filepaths, instrument configurations, etc.), the jwql application employs a configuration file to store such information. The jwql code expects this config file to be named config.json, and to be placed within the utils subpackage in individual clones of the jwql repository. This can be achieved by the following:

  1. If necessary, clone your fork of the jwql repository with git clone [email protected]:username/jwql.git (see the installation instructions for further details.
  2. Navigate to the utils/ directory
  3. Create the config file using touch config.json, or alternatively, retrieve the official jwql config file from the home directory of the jwql admin account on the jwql virtual machine.

The format of the config file should be in JSON format, for example:

{
    "my_key" : "my_val",
    "some_other_key" : "some_other_val"
}

These data can be accessed in a jwql script via the utils.py module as such:

from jwql.utils.utils import get_config
settings = get_config()
my_key = settings['my_key']

In this case, settings is a python dict containing the key/value pairs stored in the config.json file.