swagger_server/controllers/inputs_controller.py
def dataset_input_put(id, dataset):  # noqa: E501
    """Submits data to the framework

     # noqa: E501

    :param id: ID of the data source
    :type id: str
    :param dataset: Dataset submitted to the framework
    :type dataset: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        try:
            dataset = FileInputSource.from_dict(connexion.request.get_json())  # noqa: E501

            dataset = connexion.request.get_json()
            logger.info("This is the dictionary: " + str(dataset))
            input_header_validation(dataset)
            # check if the file exists
            dir = os.path.join(os.getcwd(), "optimization/resources", str(id))
            if not os.path.exists(dir):
                return "Id not existing"
            else:
                dir_file = os.path.join(dir, "Input.registry.file")
                if os.path.exists(dir_file):
                    # appends information
                    logger.info("Appending information to the file input registry")

                    with open(dir_file, 'r+') as readfile:
                        data = json.load(readfile)
                        for header in dataset:
                            data[header] = dataset[header]
                        readfile.seek(0)
                        json.dump(data, readfile)
                        readfile.truncate()
                    logger.info("data source saved into memory")
                else:
                    # saves the registry into the new folder

                    with open(dir_file, 'w') as outfile:
                        json.dump(dataset, outfile, ensure_ascii=False)
                    logger.info("data source saved into memory")

                store_data(dataset, id, "file")
                return "Data source registered", 200
        except Exception as e:
            logger.error("Invalid data " + str(e))
            return str(e).replace("\"", ""), 400
    else:
        return 'Data is not in json format', 400
Submits data to the framework

     # noqa: E501

    :param id: ID of the data source
    :type id: str
    :param dataset: Dataset submitted to the framework
    :type dataset: dict | bytes

    :rtype: None
    
Submits data to the framework
noqa: E501
Submits data to the framework noqa : E501
def dataset_input_put(id, dataset):  
    """Submits data to the framework
    :param id: ID of the data source
    :type id: str
    :param dataset: Dataset submitted to the framework
    :type dataset: dict | bytes
    :rtype: None
    """
    if connexion.request.is_json:
        try:
            dataset = FileInputSource.from_dict(connexion.request.get_json())  
            dataset = connexion.request.get_json()
            logger.info("This is the dictionary: " + str(dataset))
            input_header_validation(dataset)
            dir = os.path.join(os.getcwd(), "optimization/resources", str(id))
            if not os.path.exists(dir):
                return "Id not existing"
            else:
                dir_file = os.path.join(dir, "Input.registry.file")
                if os.path.exists(dir_file):
                    logger.info("Appending information to the file input registry")
                    with open(dir_file, 'r+') as readfile:
                        data = json.load(readfile)
                        for header in dataset:
                            data[header] = dataset[header]
                        readfile.seek(0)
                        json.dump(data, readfile)
                        readfile.truncate()
                    logger.info("data source saved into memory")
                else:
                    with open(dir_file, 'w') as outfile:
                        json.dump(dataset, outfile, ensure_ascii=False)
                    logger.info("data source saved into memory")
                store_data(dataset, id, "file")
                return "Data source registered", 200
        except Exception as e:
            logger.error("Invalid data " + str(e))
            return str(e).replace("\"", ""), 400
    else:
        return 'Data is not in json format', 400
def dataset_input_put ( id , dataset ) : if connexion . request . is_json : try : dataset = FileInputSource . from_dict ( connexion . request . get_json ( ) ) dataset = connexion . request . get_json ( ) logger . info ( "This is the dictionary: " + str ( dataset ) ) input_header_validation ( dataset ) dir = os . path . join ( os . getcwd ( ) , "optimization/resources" , str ( id ) ) if not os . path . exists ( dir ) : return "Id not existing" else : dir_file = os . path . join ( dir , "Input.registry.file" ) if os . path . exists ( dir_file ) : logger . info ( "Appending information to the file input registry" ) with open ( dir_file , 'r+' ) as readfile : data = json . load ( readfile ) for header in dataset : data [ header ] = dataset [ header ] readfile . seek ( 0 ) json . dump ( data , readfile ) readfile . truncate ( ) logger . info ( "data source saved into memory" ) else : with open ( dir_file , 'w' ) as outfile : json . dump ( dataset , outfile , ensure_ascii = False ) logger . info ( "data source saved into memory" ) store_data ( dataset , id , "file" ) return "Data source registered" , 200 except Exception as e : logger . error ( "Invalid data " + str ( e ) ) return str ( e ) . replace ( "\"" , "" ) , 400 else : return 'Data is not in json format' , 400
Submits data to the framework
 noqa: E501
Submits data to the framework noqa : E501
# noqa: E501 """Submits data to the framework

     # noqa: E501

    :param id: ID of the data source
    :type id: str
    :param dataset: Dataset submitted to the framework
    :type dataset: dict | bytes

    :rtype: None
    """ # noqa: E501 # check if the file exists # appends information # saves the registry into the new folder
None
None
id
ID of the data source
ID of the data source
dataset
Dataset submitted to the framework
Dataset submitted to the framework