swagger_server/controllers/inputs_controller.py
def dataset_input_source(File_Input_Source):  # noqa: E501
    """Creates a new data source as input

     # noqa: E501

    :param File_Input_Source: Dataset submitted to the framework
    :type File_Input_Source: dict | bytes

    :rtype: None
    """
    if connexion.request.is_json:
        try:
            File_Input_Source = FileInputSource.from_dict(connexion.request.get_json())  # noqa: E501
            logger.info("This is the dictionary: " + File_Input_Source.to_str())

            File_Input_Source = connexion.request.get_json()
            input_header_validation(File_Input_Source)

            try:
                id = utils.create_and_get_ID()
                dir_data = os.path.join(os.getcwd(), "optimization/resources", str(id), "file")
                if not os.path.exists(dir_data):
                    os.makedirs(dir_data)
                dir_data = os.path.join(os.getcwd(), "optimization/resources", str(id))
                if not os.path.exists(dir_data):
                    os.makedirs(dir_data)
            except Exception as e:
                logger.error(e)

            # saves the registry into the new folder
            path = os.path.join(os.getcwd(), "optimization/resources", str(id), "Input.registry.file")
            with open(path, 'w') as outfile:
                json.dump(File_Input_Source, outfile, ensure_ascii=False)
                logger.info("registry/input saved into memory")

            # with open(path, 'r') as file:
            input_all = File_Input_Source
            logger.debug("This is the input " + str(File_Input_Source))

            for header in input_all:
                logger.debug("Headers: " + str(header))
                input = input_all[header]

                if input:
                    logger.debug(header + " present")
                    for key in input:
                        dataset = input[key]
                        logger.debug("Data in " + str(key) + " is " + str(dataset))
                        if dataset is not None:
                            if "meta" in key:
                                file_name = str(header) + "_" + str(key) + ".txt"
                                path = os.path.join(os.getcwd(), "optimization/resources", str(id), "file",
                                                    file_name)
                                logger.debug("Path where the data is stored" + str(path))
                                # dataset = dataset.split(",")
                                with open(path, 'w') as outfile:
                                    outfile.writelines(dataset)
                            elif "SoC_Value" in key:
                                file_name = str(key) + ".txt"
                                path = os.path.join(os.getcwd(), "optimization/resources", str(id), "file",
                                                    file_name)
                                logger.debug("Path where the data is stored" + str(path))
                                # dataset = dataset.split(",")
                                with open(path, 'w') as outfile:
                                    outfile.write(str(dataset))
                            else:
                                file_name = str(key) + ".txt"
                                path = os.path.join(os.getcwd(), "optimization/resources", str(id), "file",
                                                    file_name)
                                logger.debug("Path where the data is stored" + str(path))
                                with open(path, 'w') as outfile:
                                    if isinstance(dataset, list):
                                        outfile.writelines(str(i) + '\n' for i in dataset)
                                    else:
                                        outfile.writelines(str(dataset) + '\n')
                            logger.info("input data saved into memory: " + str(file_name))
                        else:
                            logger.debug("No data in " + str(key))

            return "Instance created", 201, {'Location': str(id)}
        except Exception as e:
            logger.error("Invalid data " + str(e))
            return str(e).replace("\"", ""), 400
    else:
        return 'Data is not in json format', 400
Creates a new data source as input

     # noqa: E501

    :param File_Input_Source: Dataset submitted to the framework
    :type File_Input_Source: dict | bytes

    :rtype: None
    
Creates a new data source as input
noqa: E501
Creates a new data source as input noqa : E501
def dataset_input_source(File_Input_Source):  
    """Creates a new data source as input
    :param File_Input_Source: Dataset submitted to the framework
    :type File_Input_Source: dict | bytes
    :rtype: None
    """
    if connexion.request.is_json:
        try:
            File_Input_Source = FileInputSource.from_dict(connexion.request.get_json())  
            logger.info("This is the dictionary: " + File_Input_Source.to_str())
            File_Input_Source = connexion.request.get_json()
            input_header_validation(File_Input_Source)
            try:
                id = utils.create_and_get_ID()
                dir_data = os.path.join(os.getcwd(), "optimization/resources", str(id), "file")
                if not os.path.exists(dir_data):
                    os.makedirs(dir_data)
                dir_data = os.path.join(os.getcwd(), "optimization/resources", str(id))
                if not os.path.exists(dir_data):
                    os.makedirs(dir_data)
            except Exception as e:
                logger.error(e)
            path = os.path.join(os.getcwd(), "optimization/resources", str(id), "Input.registry.file")
            with open(path, 'w') as outfile:
                json.dump(File_Input_Source, outfile, ensure_ascii=False)
                logger.info("registry/input saved into memory")
            input_all = File_Input_Source
            logger.debug("This is the input " + str(File_Input_Source))
            for header in input_all:
                logger.debug("Headers: " + str(header))
                input = input_all[header]
                if input:
                    logger.debug(header + " present")
                    for key in input:
                        dataset = input[key]
                        logger.debug("Data in " + str(key) + " is " + str(dataset))
                        if dataset is not None:
                            if "meta" in key:
                                file_name = str(header) + "_" + str(key) + ".txt"
                                path = os.path.join(os.getcwd(), "optimization/resources", str(id), "file",
                                                    file_name)
                                logger.debug("Path where the data is stored" + str(path))
                                with open(path, 'w') as outfile:
                                    outfile.writelines(dataset)
                            elif "SoC_Value" in key:
                                file_name = str(key) + ".txt"
                                path = os.path.join(os.getcwd(), "optimization/resources", str(id), "file",
                                                    file_name)
                                logger.debug("Path where the data is stored" + str(path))
                                with open(path, 'w') as outfile:
                                    outfile.write(str(dataset))
                            else:
                                file_name = str(key) + ".txt"
                                path = os.path.join(os.getcwd(), "optimization/resources", str(id), "file",
                                                    file_name)
                                logger.debug("Path where the data is stored" + str(path))
                                with open(path, 'w') as outfile:
                                    if isinstance(dataset, list):
                                        outfile.writelines(str(i) + '\n' for i in dataset)
                                    else:
                                        outfile.writelines(str(dataset) + '\n')
                            logger.info("input data saved into memory: " + str(file_name))
                        else:
                            logger.debug("No data in " + str(key))
            return "Instance created", 201, {'Location': str(id)}
        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_source ( File_Input_Source ) : if connexion . request . is_json : try : File_Input_Source = FileInputSource . from_dict ( connexion . request . get_json ( ) ) logger . info ( "This is the dictionary: " + File_Input_Source . to_str ( ) ) File_Input_Source = connexion . request . get_json ( ) input_header_validation ( File_Input_Source ) try : id = utils . create_and_get_ID ( ) dir_data = os . path . join ( os . getcwd ( ) , "optimization/resources" , str ( id ) , "file" ) if not os . path . exists ( dir_data ) : os . makedirs ( dir_data ) dir_data = os . path . join ( os . getcwd ( ) , "optimization/resources" , str ( id ) ) if not os . path . exists ( dir_data ) : os . makedirs ( dir_data ) except Exception as e : logger . error ( e ) path = os . path . join ( os . getcwd ( ) , "optimization/resources" , str ( id ) , "Input.registry.file" ) with open ( path , 'w' ) as outfile : json . dump ( File_Input_Source , outfile , ensure_ascii = False ) logger . info ( "registry/input saved into memory" ) input_all = File_Input_Source logger . debug ( "This is the input " + str ( File_Input_Source ) ) for header in input_all : logger . debug ( "Headers: " + str ( header ) ) input = input_all [ header ] if input : logger . debug ( header + " present" ) for key in input : dataset = input [ key ] logger . debug ( "Data in " + str ( key ) + " is " + str ( dataset ) ) if dataset is not None : if "meta" in key : file_name = str ( header ) + "_" + str ( key ) + ".txt" path = os . path . join ( os . getcwd ( ) , "optimization/resources" , str ( id ) , "file" , file_name ) logger . debug ( "Path where the data is stored" + str ( path ) ) with open ( path , 'w' ) as outfile : outfile . writelines ( dataset ) elif "SoC_Value" in key : file_name = str ( key ) + ".txt" path = os . path . join ( os . getcwd ( ) , "optimization/resources" , str ( id ) , "file" , file_name ) logger . debug ( "Path where the data is stored" + str ( path ) ) with open ( path , 'w' ) as outfile : outfile . write ( str ( dataset ) ) else : file_name = str ( key ) + ".txt" path = os . path . join ( os . getcwd ( ) , "optimization/resources" , str ( id ) , "file" , file_name ) logger . debug ( "Path where the data is stored" + str ( path ) ) with open ( path , 'w' ) as outfile : if isinstance ( dataset , list ) : outfile . writelines ( str ( i ) + '\n' for i in dataset ) else : outfile . writelines ( str ( dataset ) + '\n' ) logger . info ( "input data saved into memory: " + str ( file_name ) ) else : logger . debug ( "No data in " + str ( key ) ) return "Instance created" , 201 , { 'Location' : str ( id ) } except Exception as e : logger . error ( "Invalid data " + str ( e ) ) return str ( e ) . replace ( "\"" , "" ) , 400 else : return 'Data is not in json format' , 400
Creates a new data source as input
 noqa: E501
Creates a new data source as input noqa : E501
# noqa: E501 """Creates a new data source as input

     # noqa: E501

    :param File_Input_Source: Dataset submitted to the framework
    :type File_Input_Source: dict | bytes

    :rtype: None
    """ # noqa: E501 # saves the registry into the new folder # with open(path, 'r') as file: # dataset = dataset.split(",") # dataset = dataset.split(",")
None
None
File_Input_Source
Dataset submitted to the framework
Dataset submitted to the framework