import os import gradio as gr import uuid import shutil from openvideo import push_file_to_hf try: import ml4co_kit except: os.system("pip install ml4co-kit-0.0.2a1.tar.gz") import ml4co_kit from ml4co_kit import CVRPPyVRPSolver from ml4co_kit import CVRPDataGenerator FILEPATH = "data/cvrp/uniform/cvrp100_uniform.txt" def handle( hf_token: str ): cur_iter = 0 max_iter = 1000 while(cur_iter < max_iter): solver = CVRPPyVRPSolver(time_limit=60) gen = CVRPDataGenerator( num_threads=8, nodes_num=100, min_capacity=50, max_capacity=50, solver=solver, train_samples_num=160, val_samples_num=0, test_samples_num=0 ) gen.generate() filename = uuid.uuid4().hex[:9] + ".txt" push_file_to_hf( hf_token=hf_token, hf_repo_id="ML4CO/ML4VRP", file_path=FILEPATH, path_in_repo=filename ) shutil.rmtree("data/cvrp") cur_iter = cur_iter + 1 with gr.Blocks() as demo: gr.Markdown( ''' VRP Data Generating ''' ) hf_token = gr.Textbox(label="HuggingFace Token") with gr.Row(): button = gr.Button("Submit", variant="primary") clear = gr.Button("Clear") button.click( handle, [hf_token], outputs=None ) if __name__ == "__main__": demo.launch(debug = True)