def classify(analytic_id, parameters, inputs): alg = get_class(analytic_id) initialize(alg, parameters) if alg.check_parameters(): return list(alg.classify(inputs)) else: return []
def generate_vis(vis_id, inputs, parameters): vis = get_class(vis_id) vis.initialize(inputs) print('PARAMS', parameters) initialize(vis, parameters) # if vis.check_parameters(): return vis.create()
def get_metadata(vis_id): vis = get_class(vis_id) metadata = {} metadata['name'] = vis.get_name() metadata['classname'] = vis_id.split('.')[-1] metadata['description'] = vis.get_description() metadata['parameters'] = vis.get_parameters_spec() metadata['inputs'] = vis.get_inputs() return metadata
def get_metadata(analytic_id): alg = get_class(analytic_id) metadata = {} metadata['name'] = alg.get_name() metadata['classname'] = analytic_id.split('.')[-1] metadata['description'] = alg.get_description() metadata['parameters'] = alg.get_parameters_spec() metadata['inputs'] = alg.get_inputs() metadata['outputs'] = alg.get_outputs() metadata['type'] = alg.get_type() return metadata
def get_metadata(id, api="ingest"): if api == 'ingest': mod = get_class(id) metadata = {} metadata['name'] = mod.get_name() metadata['classname'] = id.split('.')[-1] metadata['description'] = mod.get_description() metadata['parameters'] = mod.get_parameters_spec() # metadata['inputs'] = mod.get_inputs() elif api == 'filters': filt = get_class(id) metadata = {} metadata['name'] = filt.get_name() metadata['type'] = filt.get_type() metadata['stage'] = filt.get_stage() metadata['input'] = filt.get_input() metadata['outputs'] = filt.get_outputs() metadata['possible_names'] = filt.get_possible_names() metadata['classname'] = id.split('.')[-1] metadata['description'] = filt.get_description() metadata['parameters'] = filt.get_parameters_spec() return metadata
def custom(ingest_id, filepath, param1=None, param2=None, param3=None, payload=None, request={}): mod = get_class(ingest_id) return mod.custom(filepath, param1=param1, param2=param2, param3=param3, payload=payload, request=request)
def run_analysis(queue, analytic_id, parameters, inputs, storepath, name): alg = get_class(analytic_id) initialize(alg, parameters) if alg.check_parameters(): try: alg.compute(inputs, storepath=storepath, name=name) except: tb = traceback.format_exc() logging.error("Error running compute for analytics") logging.error(tb) queue.put(None) alg.write_results(storepath) print(analytic_id.split('.')[-1] + ' successful') # return alg.get_outputs() queue.put(alg.get_outputs()) else: logging.error("Check Parameters failed") queue.put(None)
def test_analysis(analytic_id, filepath, storepath): '''test_analysis: run the analytics on the matrix stored at filepath and put results in storepath. returns True if the analytic does not raise an exception when compute or write_results is called. returns False if either fails''' alg = get_class(analytic_id) initialize(alg, alg.parameters_spec) if alg.check_parameters(): try: alg.compute(filepath, storepath=storepath) alg.write_results(storepath) except: print("Running Analytic %s failed on file %s storepath=%s".format( analytic_id, filepath, storepath)) return False else: return True else: return False
def update(ingest_id, filepath): #update for function mod = get_class(ingest_id) return mod.update(filepath)
def stream(ingest_id, filepath): #update for function mod = get_class(ingest_id) multiprocessing.Process(target=mod.stream, args=[filepath]).start() return
def delete(src): mod = get_class(src['ingest_id']) return mod.delete(src['rootdir'])
def ingest(posted_data, src): mod = get_class(src['ingest_id']) return mod.ingest(posted_data, src)
def apply(filter_id, parameters, col): filt = get_class(filter_id) initialize(filt, parameters) return filt.apply(col)
def check(filter_id, name, col): filt = get_class(filter_id) return filt.check(name, col)
def explore(ingest_id, filepath, filters): mod = get_class(ingest_id) #create the object specified mod.initialize_filters(filters) return mod.explore(filepath)