def getDetectorClassConstructors(detectors): """ Takes in names of detectors. Collects class names that correspond to those detectors and returns them in a dict. The dict maps detector name to class names. Assumes the detectors have been imported. """ detectorConstructors = { d : globals()[detectorNameToClass(d)] for d in detectors} return detectorConstructors
def getDetectorClassConstructors(detectors): """ Takes in names of detectors. Collects class names that correspond to those detectors and returns them in a dict. The dict maps detector name to class names. Assumes the detectors have been imported. """ #handle py2 detectors separately: py2detectors = ",".join([ d for d in detectors if (d == "numenta" or d == "numentaTM" or d == "htmjava") ]) if py2detectors: ENV_PY2 = "./pyenv2/bin/python" argss = [] #re-parsing the arguments, as we'll provide it to a new process (python2) if args.numCPUs is not None: argss.append(" --numCPUs=" + str(args.numCPUs)) argss.append("--skipConfirmation") #always skip confirmation here # if args.detectors is not None: # argss.append("--detectors="+py2detectors) if args.dataDir: argss.append("--dataDir=" + str(args.dataDir)) if args.profilesFile: argss.append("--profilesFile=" + str(args.profilesFile)) if args.resultsDir: argss.append("--resultsDir=" + str(args.resultsDir)) if args.windowsFile: argss.append("--windowsFile=" + str(args.windowsFile)) if "htmjava" in py2detectors: # htm.java subprocess.call([ENV_PY2, "./nab/detectors/htmjava/run.py"] + argss) elif "numenta" in py2detectors or "numentaTM" in py2detectors: # Numenta* argss.append("--detectors=" + py2detectors) subprocess.call([ENV_PY2, "./nab/detectors/numenta/run.py"] + argss) detectors = [d for d in detectors if d not in py2detectors] # rm numenta*, htmjava detectorConstructors = { d: globals()[detectorNameToClass(d)] for d in detectors } return detectorConstructors
def getDetectorClassConstructors(detectors): detectorConstructors = { d:globals()[detectorNameToClass(d)] for d in detectors} return detectorConstructors
args.score = True args.normalize = True if len(args.detectors) == 1: # Handle comma-seperated list argument. args.detectors = args.detectors[0].split(',') # The following imports are necessary for getDetectorClassConstructors to # automatically figure out the detector classes. # Only import numenta detector if used so as to avoid unnecessary dependency if "numenta" in args.detectors: from nab.detectors.numenta.numenta_detector import NumentaDetector from nab.detectors.skyline.skyline_detector import SkylineDetector from nab.detectors.random.random_detector import RandomDetector from nab.detectors.null.null_detector import NullDetector detectors = [] for detector in args.detectors: if ':' in detector: package, name = detector.split(':', 2) className = detectorNameToClass(name) imprt = __import__(package, fromlist=[className]) globals().update({className: getattr(imprt, className)}) detectors.append(name) else: detectors.append(detector) args.detectors = detectors if args.skipConfirmation or checkInputs(args): main(args)