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. 2
      server/src/config.ts
  5. 1
      server/src/controllers/analytics_controller.ts

4
analytics/anomaly_model.py

@ -124,11 +124,11 @@ class AnomalyModel:
self.preprocessor.synchronize()
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)
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):
return []
with open(labeled_anomalies_file) as file:

13
analytics/config.py

@ -2,8 +2,9 @@ import os
import json
DATA_FOLDER = '../data'
CONFIG_FILE = '../config.json'
PARENT_FOLDER = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
DATA_FOLDER = os.path.join(PARENT_FOLDER, 'data')
CONFIG_FILE = os.path.join(PARENT_FOLDER, 'config.json')
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/')
ANOMALIES_FOLDER = os.path.join(DATA_FOLDER, 'anomalies/')
MODELS_FOLDER = os.path.join(DATA_FOLDER, 'models/')
METRICS_FOLDER = os.path.join(DATA_FOLDER, 'metrics/')
DATASET_FOLDER = os.path.join(DATA_FOLDER, 'datasets')
ANALYTIC_UNITS_FOLDER = os.path.join(DATA_FOLDER, 'analytic_units')
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')
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)
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)
def __save_model(self):

2
server/src/config.ts

@ -11,7 +11,7 @@ export const ANALYTICS_PATH = path.join(__dirname, '../../analytics');
export const DATA_PATH = path.join(__dirname, '../../data');
export const DATASETS_PATH = path.join(DATA_PATH, 'datasets');
export const ANALYTIC_UNITS_PATH = path.join(DATA_PATH, 'analytic_units ');
export const ANALYTIC_UNITS_PATH = path.join(DATA_PATH, 'analytic_units');
export const MODELS_PATH = path.join(DATA_PATH, 'models');
export const METRICS_PATH = path.join(DATA_PATH, 'metrics');
export const SEGMENTS_PATH = path.join(DATA_PATH, 'segments');

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) {
let unit = AnalyticUnit.findById(id);
let pattern = unit.type;

Loading…
Cancel
Save