def load_forms(plot_type): if not check_plot_type(plot_type): raise ValueError("Invalid Plot Type") data_setting = io.load(plot_type+'_data_setting') config = io.load(plot_type+'_config') interaction_config = io.load(plot_type+'_interaction_config') if data_setting is None or config is None: raise ValueError("Cannot load forms from redis, cache missing") if interaction_config is None: return data_setting, config else: return data_setting, config, interaction_config
def request_training(): setting = io.load('MLM::training::setting') config = io.load('MLM::training::config') setting = form_dicts_to_dict(setting) config = form_dicts_to_dict(config) if setting['data']['value'] == '' or setting['model']['value'] == '': return flask.jsonify(result=False) data_frame_ids = [int(_id) for _id in str(setting['data']['value']).split(",")] models = str(setting['model']['value']).split(",") data_frames = [data_pool.load_training(_id) for _id in data_frame_ids] for data_frame in data_frames: for model in models: train(data_frame, model, config) return flask.jsonify(result=True)
def set_data_setting(): setting = io.load('MLM::training::setting') setting_input = flask.request.args setting = process_form_input('setting', setting, setting_input) print(setting) io.save('MLM::training::setting', setting) return flask.jsonify(result=True)
def load_interaction_config(plot_type): if not check_plot_type(plot_type): raise ValueError("Invalid Plot Type") interaction_config = io.load(plot_type + '_interaction_config') if interaction_config is None: raise ValueError("Cannot load forms from redis, cache missing") return interaction_config
def load_data_setting(plot_type): if not check_plot_type(plot_type): raise ValueError("Invalid Plot Type") data_setting = io.load(plot_type + '_data_setting') if data_setting is None: raise ValueError("Cannot load forms from redis, cache missing") return data_setting
def interactive_query_cache(interactive_plot_type): (data_setting, config, interaction_config) = load_forms(interactive_plot_type) return flask.jsonify( dict(selected_frame_id=io.load('selected_frame_id'), data_setting=data_setting, config=config, interation_config=interaction_config))
def fetch(): global connector cfg_mysql = io.load('MLV::config::cfg_mysql') if not cfg_mysql: return "No MySQL config dict provided" connector = Connector(cfg_mysql) connector.open_conn() html = flask.render_template('fetching/fetch.html', ) return html
def training(): global data_pool global classifier_pool data_pool = DataPool() classifier_pool = ClassifierPool() setting = initialize_form_dicts(FORM_DICT['setting']) config = initialize_form_dicts(FORM_DICT['config']) io.save('MLM::training::setting', setting) io.save('MLM::training::config', config) setting = io.load('MLM::training::setting') config = io.load('MLM::training::config') if setting is None or config is None: raise ValueError("Cannot load forms from redis, cache missing") html = flask.render_template( 'training/training.html', setting=setting, config=config, ) return html
def set_selected_features(): selected_feature_id_ids = str( flask.request.args.get('selected_feature_id_ids', None)).split(',') selected_feature_id_ids = [ int(selected_id) for selected_id in selected_feature_id_ids ] selected_feature_ids = [ feature_id_frame.publish_dict()[selected_id]['feature_id'] for selected_id in selected_feature_id_ids ] selected_feature_names = [ feature_id_frame.publish_dict()[selected_id]['feature_name'] for selected_id in selected_feature_id_ids ] io.save('selected_feature_ids', selected_feature_ids) io.save('selected_feature_names', selected_feature_names) selected_feature_table = str(io.load('selected_feature_table')) return flask.jsonify(result=connector.save_features( selected_feature_table, selected_feature_ids, selected_feature_names))
def set_config(): config = io.load('MLM::training::config') config_input = flask.request.args config = process_form_input('config', config, config_input) io.save('MLM::training::config', config) return flask.jsonify(result=True)
def get_config(): config = io.load('MLM::training::config') return flask.jsonify(result=config)
def get_data_setting(): setting = io.load('MLM::training::setting') return flask.jsonify(result=setting)
def __init__(self): self.pool = io.load(self.name_prefix) if io.load( self.name_prefix) else []
def load_selected_frame_id(plot_type): if not check_plot_type(plot_type): raise ValueError("Invalid Plot Type") selected_frame_id = io.load(plot_type+'_selected_frame_id') return selected_frame_id
def static_query_cache(static_plot_type): (data_setting, config) = load_forms(static_plot_type) return flask.jsonify( dict(selected_frame_id=io.load('selected_frame_id'), data_setting=data_setting, config=config))