import gradio as gr from queue import PriorityQueue from datetime import datetime pq = PriorityQueue() date_format = '%m-%d-%Y at %H:%M' import os def writer(pair): final = pair[1] + ' is due on ' final += f'{pair[0].month:02}-{pair[0].day:02}-{pair[0].year} at ' final += f'{pair[0].hour:02}:{pair[0].minute:02}' return final def string_rep(pq): work = "" temp = PriorityQueue() while not pq.empty(): elem = pq.get() temp.put(elem) work += writer(elem) + '\n' pq.queue = temp.queue return work def inputter(date_str = None, item_name = None, add = "Show"): if add == "Show": return string_rep(pq) cur_date = datetime.strptime(date_str, date_format) item_name = item_name.strip() if add == "Add": pq.put((cur_date, item_name)) else: remove((cur_date, item_name)) return string_rep(pq) def remove(element): temp = PriorityQueue() while not pq.empty(): elem = pq.get() if elem != element: temp.put(elem) pq.queue = temp.queue datalink = gr.Textbox(label="Enter your data link here:", placeholder="e.g., https://sample_data.tar.gz") databox = gr.Textbox(label="Enter your data type here:", placeholder="e.g., images, genome, binary") augbox = gr.Textbox(label="Enter your data augmentation methods here:", placeholder="Enter as list e.g., [flip, rotate]") machinebox = gr.Textbox(label="Enter your machine type:", placeholder="e.g., transformer, SVM, CNN") featurebox = gr.Textbox(label="Enter your features type:", placeholder="e.g., KL-expansion, Lagragians") ouputbox = gr.Textbox(label="Output", placeholder="Accuracy: 100%", lines = 10) iface = gr.Interface( fn=inputter, inputs=[datalink, databox, augbox, featurebox, machinebox], outputs=ouputbox, title="Cancer Metapipeline", ) iface.launch()