Browse Source
* Add config example * Make python use config file * Make node use config file * Update docspull/1/head
7 changed files with 83 additions and 17 deletions
@ -1,7 +1,30 @@ |
|||||||
import os |
import os |
||||||
|
import json |
||||||
|
|
||||||
|
def get_config_field(field, default_val = None): |
||||||
|
val = default_val |
||||||
|
|
||||||
|
config_exists = os.path.isfile(CONFIG_FILE) |
||||||
|
if config_exists: |
||||||
|
with open(CONFIG_FILE) as f: |
||||||
|
config = json.load(f) |
||||||
|
|
||||||
|
if field in os.environ: |
||||||
|
val = os.environ[field] |
||||||
|
elif config_exists and field in config: |
||||||
|
val = config[field] |
||||||
|
else: |
||||||
|
raise Exception('Please configure {}'.format(field)) |
||||||
|
|
||||||
|
return val |
||||||
|
|
||||||
DATA_FOLDER = '../data' |
DATA_FOLDER = '../data' |
||||||
DATASET_FOLDER = os.path.join(DATA_FOLDER, "datasets/") |
CONFIG_FILE = '../config.json' |
||||||
ANOMALIES_FOLDER = os.path.join(DATA_FOLDER, "anomalies/") |
|
||||||
MODELS_FOLDER = os.path.join(DATA_FOLDER, "models/") |
DATASET_FOLDER = os.path.join(DATA_FOLDER, 'datasets/') |
||||||
METRICS_FOLDER = os.path.join(DATA_FOLDER, "metrics/") |
ANOMALIES_FOLDER = os.path.join(DATA_FOLDER, 'anomalies/') |
||||||
|
MODELS_FOLDER = os.path.join(DATA_FOLDER, 'models/') |
||||||
|
METRICS_FOLDER = os.path.join(DATA_FOLDER, 'metrics/') |
||||||
|
|
||||||
|
HASTIC_API_KEY = get_config_field('HASTIC_API_KEY') |
||||||
|
|
||||||
|
@ -0,0 +1,4 @@ |
|||||||
|
{ |
||||||
|
"HASTIC_PORT": 8000, |
||||||
|
"HASTIC_API_KEY": "eyJrIjoiVjZqMHY0dHk4UEE3eEN4MzgzRnd2aURlMWlIdXdHNW4iLCJuIjoiaGFzdGljIiwiaWQiOjF9" |
||||||
|
} |
Loading…
Reference in new issue