Skip to content

Config file

Teagan King edited this page Jun 3, 2021 · 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 main directory 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 jwql/ directory of where the package is installed.
  2. A file called example_config.json already exists. It is named as such to help avoid accidentally committing a complete configuration file with sensitive information to the repository. Make a copy of this called config.json and save the file. The file should look like the template below.
{
    "admin_account" : "",
    "auth_mast" : "",
    "client_id" : "",
    "client_secret" : "",
    "connection_string" : "",
    "database" : {
        "engine" : "",
        "name" : "",
        "user" : "",
        "password" : "",
        "host" : "",
        "port" : ""
    },
    "jwql_dir" : "",
    "jwql_version": "",
    "server_type": "",
    "log_dir" : "",
    "mast_token" : "",
    "outputs" : "",
    "preview_image_filesystem" : "",
    "filesystem" : "",
    "setup_file" : "",
    "test_data" : "",
    "test_dir" : "",
    "thumbnail_filesystem" : "",
    "cores" : ""
}

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.