Browse Source

config paths fixs

pull/1/head
Alexey Velikiy 6 years ago
parent
commit
95b5f69788
  1. 4
      analytics/anomaly_model.py
  2. 13
      analytics/config.py
  3. 2
      analytics/pattern_detection_model.py
  4. 1
      server/src/controllers/analytics_controller.ts

4
analytics/anomaly_model.py

@ -124,11 +124,11 @@ class AnomalyModel:
self.preprocessor.synchronize() self.preprocessor.synchronize()
def load_anomaly_config(self): def load_anomaly_config(self):
with open(os.path.join(config.ANOMALIES_FOLDER, self.anomaly_name + ".json"), 'r') as config_file: with open(os.path.join(config.ANALYTIC_UNITS_FOLDER, self.anomaly_name + ".json"), 'r') as config_file:
self.anomaly_config = json.load(config_file) self.anomaly_config = json.load(config_file)
def get_anomalies(self): def get_anomalies(self):
labeled_anomalies_file = os.path.join(config.ANOMALIES_FOLDER, self.anomaly_name + "_labeled.json") labeled_anomalies_file = os.path.join(config.ANALYTIC_UNITS_FOLDER, self.anomaly_name + "_labeled.json")
if not os.path.exists(labeled_anomalies_file): if not os.path.exists(labeled_anomalies_file):
return [] return []
with open(labeled_anomalies_file) as file: with open(labeled_anomalies_file) as file:

13
analytics/config.py

@ -2,8 +2,9 @@ import os
import json import json
DATA_FOLDER = '../data' PARENT_FOLDER = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
CONFIG_FILE = '../config.json' DATA_FOLDER = os.path.join(PARENT_FOLDER, 'data')
CONFIG_FILE = os.path.join(PARENT_FOLDER, 'config.json')
config_exists = os.path.isfile(CONFIG_FILE) config_exists = os.path.isfile(CONFIG_FILE)
@ -27,10 +28,10 @@ def get_config_field(field, default_val = None):
DATASET_FOLDER = os.path.join(DATA_FOLDER, 'datasets/') DATASET_FOLDER = os.path.join(DATA_FOLDER, 'datasets')
ANOMALIES_FOLDER = os.path.join(DATA_FOLDER, 'anomalies/') ANALYTIC_UNITS_FOLDER = os.path.join(DATA_FOLDER, 'analytic_units')
MODELS_FOLDER = os.path.join(DATA_FOLDER, 'models/') MODELS_FOLDER = os.path.join(DATA_FOLDER, 'models')
METRICS_FOLDER = os.path.join(DATA_FOLDER, 'metrics/') METRICS_FOLDER = os.path.join(DATA_FOLDER, 'metrics')
HASTIC_API_KEY = get_config_field('HASTIC_API_KEY') HASTIC_API_KEY = get_config_field('HASTIC_API_KEY')
ZEROMQ_CONNECTION_STRING = get_config_field('ZEROMQ_CONNECTION_STRING', 'tcp://*:8002') ZEROMQ_CONNECTION_STRING = get_config_field('ZEROMQ_CONNECTION_STRING', 'tcp://*:8002')

2
analytics/pattern_detection_model.py

@ -101,7 +101,7 @@ class PatternDetectionModel:
return StepDetector(pattern) return StepDetector(pattern)
def __load_anomaly_config(self): def __load_anomaly_config(self):
with open(os.path.join(config.ANOMALIES_FOLDER, self.analytic_unit_id + ".json"), 'r') as config_file: with open(os.path.join(config.ANALYTIC_UNITS_FOLDER, self.analytic_unit_id + ".json"), 'r') as config_file:
self.anomaly_config = json.load(config_file) self.anomaly_config = json.load(config_file)
def __save_model(self): def __save_model(self):

1
server/src/controllers/analytics_controller.ts

@ -59,6 +59,7 @@ export async function runLearning(id: AnalyticUnit.AnalyticUnitId) {
} }
} }
export async function runPredict(id: AnalyticUnit.AnalyticUnitId) { export async function runPredict(id: AnalyticUnit.AnalyticUnitId) {
let unit = AnalyticUnit.findById(id); let unit = AnalyticUnit.findById(id);
let pattern = unit.type; let pattern = unit.type;

Loading…
Cancel
Save