Update app.py
Browse files2 unmodified lines3456781 unmodified line10111213141516171819202122232425262728293031323334352 unmodified linesfrom huggingface_hub.repository import Repositoryimport gradio as grimport pandas as pdimport tempfiletoken = gr.Textbox(label = "Your Hugging Face Token")1 unmodified linedataset_name = gr.Textbox(label = "Dataset Name")dataset = gr.File(label = "Dataset")output_text = gr.Textbox(label = "Status")title = "Dataset Profiler 🪄✨"description = "Drag and drop any dataset you want to get a detailed profile on, and this Space will profile and push it to your Hub profile as a new Space. 🌟✨"def profile_dataset(dataset, username, token, dataset_name):df = pd.read_csv(dataset.name)profile = pp.ProfileReport(df, title=f"{dataset_name} Report")url = create_repo(f"{username}/{dataset_name}", repo_type = "space", token = token, space_sdk = "static")repo = Repository(local_dir = f"{username}/{dataset_name}",clone_from=url,use_auth_token=token,repo_type = "space")repo.git_pull(rebase=True)profile.to_file(f"{username}/{dataset_name}/index.html")repo.git_add()repo.git_commit(commit_message = "Dataset report")repo.git_push()return f"Your dataset report will be ready at {url}"gr.Interface(profile_dataset, inputs = [dataset, username, token, dataset_name], description = description, title = title, outputs=[output_text], enable_queue = True).launch(debug=True)2 unmodified lines3456789101 unmodified line121314151617181920212223242526272829303132333435363738394041422 unmodified linesfrom huggingface_hub.repository import Repositoryimport gradio as grimport pandas as pdimport subprocessimport osimport tempfiletoken = gr.Textbox(label = "Your Hugging Face Token")1 unmodified linedataset_name = gr.Textbox(label = "Dataset Name")dataset = gr.File(label = "Dataset")output_text = gr.Textbox(label = "Status")def profile_dataset(dataset, username, token, dataset_name):df = pd.read_csv(dataset.name)profile = pp.ProfileReport(df, title=f"{dataset_name} Report")repo_url = create_repo(f"{username}/{dataset_name}", repo_type = "space", token = token, space_sdk = "static")subprocess.run(f"git clone {repo_url}".split(),encoding="utf-8",cwd= os.getcwd(),check=True,env=os.environ.copy(),)repo = Repository(clone_from = repo_url,local_dir=f"{username}/{dataset_name}")profile.to_file(f"{username}/{dataset_name}/index.html")repo.git_add()repo.git_commit(commit_message = "Dataset report")repo.git_push()return f"Your dataset report will be ready at {repo_url}"gr.Interface(profile_dataset, inputs = [dataset, username, token, dataset_name], outputs=[output_text], enable_queue = True).launch(debug=True)
app.py+17-10