def load_data(): ''' This method returns the computed data, resulting from one of the following implemented session: - data_new - data_append - model_predict - model_generate ''' if request.method == 'POST': # get uploaded form files if request.files: files = request.files else: files = None # web-interface: get submitted form data if request.form: settings = request.form sender = Settings(settings, files) data_formatted = sender.restructure() # send reformatted data to brain loader = Load_Data(data_formatted) if loader.get_session_type()['session_type']: session_type = loader.get_session_type()['session_type'] if session_type == 'data_new': response = loader.load_data_new() elif session_type == 'data_append': response = loader.load_data_append() elif session_type == 'model_generate': response = loader.load_model_generate() elif session_type == 'model_predict': response = loader.load_model_predict() else: response = loader.get_errors() else: response = loader.get_errors() # return response return response
def load_data(): ''' This method returns the computed data, resulting from one of the following implemented session: - data_new - data_append - model_predict - model_generate Note: more information on flask-jwt partially protecting routes: http://flask-jwt-extended.readthedocs.io/en/latest/optional_endpoints.html ''' if request.method == 'POST': current_user = get_jwt_identity() # programmatic-interface if request.get_json(): # send data to brain loader = Load_Data(request.get_json(), current_user) if loader.get_session_type()['session_type']: session_type = loader.get_session_type()['session_type'] if session_type == 'data_new': response = loader.load_data_new() elif session_type == 'data_append': response = loader.load_data_append() elif session_type == 'model_generate': response = loader.load_model_generate() elif session_type == 'model_predict': response = loader.load_model_predict() else: response = loader.get_errors() else: response = loader.get_errors() # return response return response
def load_data(): ''' This method returns the computed data, resulting from one of the following implemented session: - data_new - data_append - model_predict - model_generate ''' if request.method == 'POST': # load programmatic-interface if request.get_json(): # get necessary components from the dataset if 'dataset' in request.get_json(): dataset = request.get_json()['dataset'] else: dataset = None settings = request.get_json()['properties'] # restructure the dataset sender = Restructure_Settings(settings, dataset) data_formatted = sender.restructure() # send reformatted data to brain loader = Load_Data(data_formatted) if loader.get_session_type()['session_type']: session_type = loader.get_session_type()['session_type'] if session_type == 'data_new': response = loader.load_data_new() elif session_type == 'data_append': response = loader.load_data_append() elif session_type == 'model_generate': response = loader.load_model_generate() elif session_type == 'model_predict': response = loader.load_model_predict() else: response = loader.get_errors() else: response = loader.get_errors() # return response return response # load web-interface else: # local variables files = None # get uploaded form files if request.files: files = request.files # get submitted form data if request.form: settings = request.form sender = Restructure_Settings(settings, files) data_formatted = sender.restructure() # send reformatted data to brain loader = Load_Data(data_formatted) if loader.get_session_type()['session_type']: session_type = loader.get_session_type()['session_type'] if session_type == 'data_new': response = loader.load_data_new() elif session_type == 'data_append': response = loader.load_data_append() elif session_type == 'model_generate': response = loader.load_model_generate() elif session_type == 'model_predict': response = loader.load_model_predict() else: response = loader.get_errors() else: response = loader.get_errors() # return response return response
def load_data(): '''@load_data This method returns the computed data, resulting from one of the following implemented session: - data_new - data_append - model_predict - model_generate ''' if request.method == 'POST': # load programmatic-interface if request.get_json(): # get necessary components from the dataset if 'dataset' in request.get_json(): dataset = request.get_json()['dataset'] else: dataset = None settings = request.get_json()['properties'] # restructure the dataset sender = Restructure_Settings(settings, dataset) data_formatted = sender.restructure() # send reformatted data to brain loader = Load_Data(data_formatted) if loader.get_session_type()['session_type']: session_type = loader.get_session_type()['session_type'] if session_type == 'data_new': response = loader.load_data_new() elif session_type == 'data_append': response = loader.load_data_append() elif session_type == 'model_generate': response = loader.load_model_generate() elif session_type == 'model_predict': response = loader.load_model_predict() else: response = loader.get_errors() else: response = loader.get_errors() # return response return json.dumps(response) # load web-interface else: # local variables files = None # get uploaded form files if request.files: files = request.files # get submitted form data if request.form: settings = request.form sender = Restructure_Settings(settings, files) data_formatted = sender.restructure() # send reformatted data to brain loader = Load_Data(data_formatted) if loader.get_session_type()['session_type']: session_type = loader.get_session_type()['session_type'] if session_type == 'data_new': response = loader.load_data_new() elif session_type == 'data_append': response = loader.load_data_append() elif session_type == 'model_generate': response = loader.load_model_generate() elif session_type == 'model_predict': response = loader.load_model_predict() else: response = loader.get_errors() else: response = loader.get_errors() # return response return json.dumps(response)