diff --git a/src/analyzer/algorithms.py b/src/analyzer/algorithms.py index 77a05d21..9af571bb 100644 --- a/src/analyzer/algorithms.py +++ b/src/analyzer/algorithms.py @@ -4,11 +4,14 @@ import statsmodels.api as sm import traceback import logging +import imp +import sys from time import time from msgpack import unpackb, packb from redis import StrictRedis from settings import ( + CUSTOM_ALGORITHM_MODULE, ALGORITHMS, CONSENSUS, FULL_DURATION, @@ -22,6 +25,16 @@ from algorithm_exceptions import * +# If you have a custom module for algorithms, load it here and inject into globals +if CUSTOM_ALGORITHM_MODULE: + try: + m = imp.load_module(CUSTOM_ALGORITHM_MODULE, *imp.find_module(CUSTOM_ALGORITHM_MODULE)) + sys.modules['tmp_algorithms'] = m + from tmp_algorithms import * + except: + pass + + logger = logging.getLogger("AnalyzerLog") redis_conn = StrictRedis(unix_socket_path=REDIS_SOCKET_PATH) diff --git a/src/settings.py.example b/src/settings.py.example index c128fe88..dbb6a9bf 100644 --- a/src/settings.py.example +++ b/src/settings.py.example @@ -99,6 +99,10 @@ ALGORITHMS = [ 'ks_test', ] +# This allows a custom module to be loaded into the global namespace of the algorithm.py +# file. Use this to bring in function from outside of skyline +CUSTOM_ALGORITHM_MODULE = '' + # This is the number of algorithms that must return True before a metric is # classified as anomalous. CONSENSUS = 6