Skip to content

Configuration

Rukmal Weerawarana edited this page Jul 3, 2018 · 2 revisions

Overview

This section describes the configuration settings used in PaperRank. The PaperRank configuration files are located in the config/ directory in the project parent directory. Unless the full path is explicitly stated, assume all references to files in this section are with respect to the config/ directory.

Before using the application, configuration variables must be ingested. This step does not happen automatically, and must be run by the user on instantiation. The configuration utility provides the following options:

import PaperRank

# No override, base configuration
PaperRank.util.configSetup()

# With override, use 'default.json' in config folder
PaperRank.util.configSetup(override='default.json')

Configuration File Structure

The bare-minimum configuration required for the application to run is the base.json file. Note that the test.json file is used by the package tests to ensure the override functionality is behaving as expected.

The structure of the base.json configuration file is as follows:

{
    "redis": {

    },
    "ncbi_api": {
         "api_key": null
    },
    "test": {
        "redis": {

        }
    }
}

The categories are self-explanatory, however it is important to note that the test Redis database MUST be different than the production database. The test sequences repeatedly flush the entire database.

Encrypting and Decrypting Configuration Files

Note: If you are a developer of PaperRank, click here for the decryption password.

The Makefile in the project root includes rules to encrypt and decrypt configuration files with a password, so that they can be shared easily, and checked into version control. The rules are designed to encrypt all JSON files (excluding base.json and test.json), and to decrypt all CAST5 files in the config/ directory.

  • Encrypt configuration files
$ make config_encrypt
  • Decrypt configuration files
$ make config_decrypt

Overriding Parameters

There are some values in the configuration that must be set by the user. The PaperRank configuration ingestion architecture provides an easy method for doing this. First, create an override file with the variables you want to override.

Note: It is necessary that this file follow the same structure as base.json.

For example, consider that you want to override the api_key variable with a value from your NCBI account. This can be done by creating a default.json file as follows:

    "ncbi_api": {
         "api_key": "my_api_key"
    },

Following this, the configuration setup function can be called with the override flag enabled, as follows:

import PaperRank

# Set up PaperRank configuration, with override
PaperRank.util.configSetup(override='default.json')

This option provides the same functionality as editing the main configuration directly. Compartmentalizing configuration files in this way allows for separate sets of production and development configuration variables without excessive overhead.

Clone this wiki locally