Browse Source

rm ANALYTIC_UNITS_FOLDER usage (#108)

pull/1/head
Alexey Velikiy 6 years ago committed by rozetko
parent
commit
6aa8158711
  1. 1
      analytics/config.py
  2. 12
      analytics/detectors/general_detector/general_detector.py
  3. 4
      analytics/detectors/pattern_detector.py

1
analytics/config.py

@ -28,7 +28,6 @@ def get_config_field(field, default_val = None):
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')

12
analytics/detectors/general_detector/general_detector.py

@ -19,7 +19,6 @@ class GeneralDetector:
def __init__(self, anomaly_name):
self.anomaly_name = anomaly_name
self.load_anomaly_config()
parsedUrl = urlparse(self.anomaly_config['panelUrl'])
origin = parsedUrl.scheme + '://' + parsedUrl.netloc
@ -109,17 +108,6 @@ class GeneralDetector:
self.preprocessor.set_data_provider(self.data_prov)
self.preprocessor.synchronize()
def load_anomaly_config(self):
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.ANALYTIC_UNITS_FOLDER, self.anomaly_name + "_labeled.json")
if not os.path.exists(labeled_anomalies_file):
return []
with open(labeled_anomalies_file) as file:
return json.load(file)
def create_algorithm(self):
return SupervisedAlgorithm()

4
analytics/detectors/pattern_detector.py

@ -98,10 +98,6 @@ class PatternDetector:
def synchronize_data(self):
self.data_prov.synchronize()
def __load_anomaly_config(self):
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):
logger.info("Save model '%s'" % self.analytic_unit_id)
model_filename = os.path.join(config.MODELS_FOLDER, self.analytic_unit_id + ".m")

Loading…
Cancel
Save