Skip to content

Config file

Matthew Bourque edited this page Nov 16, 2020 · 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 you have not yet done so, install the jwql package. See the installation instructions for further details.
  2. Determine the installation location of the package. You can do this through Python via:
import jwql
print(jwql.__path__)
  1. Navigate to the utils/ directory of where the package is installed.
  2. Using the template below, create a config.json file and save it in the utils/ directory.
{
    "admin_account" : "",
    "auth_mast" : "",
    "client_id" : "",
    "client_secret" : "",
    "connection_string" : "",
    "cores" : 4,
    "database" : {
        "engine" : "",
        "name" : "",
        "user" : "",
        "password" : "",
        "host" : "",
        "port" : ""
    },
    "jwql_dir" : "",
    "log_dir" : "",
    "mast_token" : "",
    "outputs" : "",
    "preview_image_filesystem" : "",
    "filesystem" : "",
    "setup_file" : "",
    "test_data" : "",
    "test_dir" : "",
    "thumbnail_filesystem" : ""
}

Since some of these data contain sensitive information, we do not provide the actual values here. Please ask a JWQL team member or email [email protected] if you need assistance filling out the template.

These data can be accessed in a jwql script via the utils.py module, for example:

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

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