def guessDebug(): # Data before test data = { "dep_loc": None, "dep_date": None, "dep_hour": None, "arr_loc": None, "arr_date": None, "arr_hour": None } # Dynamic test from src.normalize import normalize from src.extract import extract testSentences = [input("Enter a sentence to test: ")] testSentences[0] = extract(normalize(testSentences[0])) # If extract() or normalise() are not working properly, it is best to use # hand made sentences rather than calling those functions # testSentences = ["good morning !", # "i'd like to book a flight", # "from P_Paris to P_Dublin at D_030403"] # Prints data after the tests for values in testSentences: print("=> " + values) guess(values, data) print(data)
def pipe(event, context): print(event) raw = extract(event) print(raw) transformed = transform(raw.values.tolist()) print(transformed) load(transformed)
def main(): dataset = extract(INPUT_DATA_FILEPATH, FDS2019CustomParser()) cleaned_dataset = transform_2019_fds_data(dataset, mapping_filepaths) longform_formatter = LongformFormatter(FDS2019CustomFormatter(), longform_column_order) formatted_longform_dataset = field_remover.remove_from(format_dataset(cleaned_dataset, longform_formatter)) CSVWriter(formatted_longform_dataset).write(LONGFORM_OUTPUT_FILEPATH) shortform_formatter = ShortformFormatter(FDS2019CustomFormatter(), shortform_column_order) formatted_shortform_dataset = format_dataset(cleaned_dataset, shortform_formatter) CSVWriter(formatted_shortform_dataset).write(SHORTFORM_OUTPUT_FILEPATH)
def etl_accident(): for file in INPUT_DATA_GOUV_URL: year = file.get("year") print(year) dict = {} for input_url in file.get("urls"): url = input_url.get("url") type = input_url.get("type") data = extract(url, type) data = transform(data, type) dict[type] = data load(dict['vehicles'], dict['users'], dict['places'], dict['characteristics'])
def checkinbot(): data = { "dep_loc": None, "dep_date": None, "dep_hour": None, "arr_loc": None, "arr_date": None, "arr_hour": None, "special": None } print("Hi! My name is Checkinbot, I am here to help you book a flight\n" + "from any capital city in western Europe to any capital city in\n" + "the same zone.\n" + "To start things off, could you tell me what is your travel plan?") run = True while (run): userInput = input("> ") modified = guess(extract(normalize(userInput)), data) run = answer(data)
def solver_endpoints(path): n_videos, n_endpoints, n_requests, n_servers, server_space, video_sizes, endpoints, requests = extract.extract( path) videos_sorted = sort_videos( requests, video_sizes ) # pour chaque endpoint, liste des videos par ordre de requests maximal server_sorted_by_latency = sort_endpoints_by_latency( endpoints ) # pour chaque endpoint, liste des servers classes par ordre de latence min add_list = [ 1 for i in range(n_endpoints) ] # pour chaque endpoint, 1 si on a ajoute une video ce tour ci, 0 sinon # condition d'arret : tout vaut 0, on n'a rien ajoute output_list = [[] for i in range(n_servers)] while sum(add_list) != 0: for i in range(len(endpoints)): add_done = False while not add_done and server_sorted_by_latency[i] != []: serv_min = server_sorted_by_latency[i][ 0] # serveur de latence minimale par rapport au endpoint i j = 0 # tentatives d'ajout while j < 1 and not add_done: # 4 tentatives max avant de passer au serveur suivant if j < len( videos_sorted[i] ) and videos_sorted[i][j] not in output_list[ serv_min]: # video avec le plus de requetes pour l'endpoint i, si elle n'y est pas add_video( output_list, serv_min, videos_sorted[i][j], video_sizes, server_space ) # n'ajoute pas si ca depasse la taille du serveur ou si elle y est deja add_done = True delete_video( videos_sorted, i, j ) # on supprime la video de la liste des plus populaires vu qu'elle est accessible else: j += 1 # on tente d'inserer la video du rang d'apres if not add_done: delete_server(server_sorted_by_latency, i) # on supprime le serveur des accessibles if not add_done: add_list[i] = 0 else: add_list[i] = 1 return output_list
i_video, amount * 1000 / video_sizes[i_video] ] for i_video, amount in enumerate(requests_t[i_endpoint]) if amount > 0] result.append([ data[0] for data in sorted(requests_in_endpoint, key=lambda data: -data[1]) ]) return result def sort_endpoints_by_latency(endpoints): result = [] for i_endpoint, endpoints in enumerate(endpoints): servers_to_endpoint_latency = endpoints[1] servers = [[i, latency] for i, latency in enumerate(servers_to_endpoint_latency) if latency != math.inf] result.append( [data[0] for data in sorted(servers, key=lambda data: data[1])]) return result def delete_server(server_sorted_by_latency, i): del server_sorted_by_latency[i][0] if __name__ == "__main__": n_videos, n_endpoints, n_requests, n_servers, server_space, video_sizes, endpoints, requests = extract.extract( extract.names[0]) result = sort_videos_by_request(requests) print(result)
from src.server.instance import server from src.controllers.load import * from src.extract import extract from src.transform import transform if __name__ == '__main__': extract() transform() server.run()