From 9e2eacf2dbca21a9f05ed7b2378cf45bde42d06a Mon Sep 17 00:00:00 2001 From: "sweep-nightly[bot]" <131841235+sweep-nightly[bot]@users.noreply.github.com> Date: Sat, 8 Jul 2023 08:34:05 +0000 Subject: [PATCH] Update sweepai/app/ui.py --- sweepai/app/ui.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sweepai/app/ui.py b/sweepai/app/ui.py index 69be2c5587..e30090ef73 100644 --- a/sweepai/app/ui.py +++ b/sweepai/app/ui.py @@ -1,5 +1,6 @@ import json import os +import tempfile from git import Repo from github import Github import gradio as gr @@ -97,16 +98,17 @@ def get_files(repo_full_name): repo = github_client.get_repo(repo_full_name) repo_url = f"https://x-access-token:{config.github_pat}@github.com/{repo_full_name}.git" try: - if os.path.exists("/tmp/" + repo_full_name): - git_repo = Repo("/tmp/" + repo_full_name) + repo_dir = os.path.join(tempfile.gettempdir(), repo_full_name) + if os.path.exists(repo_dir): + git_repo = Repo(repo_dir) git_repo.remotes.origin.pull() else: - Repo.clone_from(repo_url, "/tmp/" + repo_full_name) + Repo.clone_from(repo_url, repo_dir) except Exception as e: logger.warning(f"Git pull failed with error {e}, deleting cache and recloning...") - shutil.rmtree("/tmp/" + repo_full_name) - Repo.clone_from(repo_url, "/tmp/" + repo_full_name) - all_files, path_to_contents = get_files_recursively("/tmp/" + repo_full_name) + shutil.rmtree(repo_dir) + Repo.clone_from(repo_url, repo_dir) + all_files, path_to_contents = get_files_recursively(repo_dir) return all_files def get_files_update(*args): @@ -117,7 +119,6 @@ def get_files_update(*args): repo = config.repo_full_name return gr.Dropdown.update(choices=get_files(repo)) - with gr.Blocks(theme=gr.themes.Soft(), title="Sweep Chat", css=css) as demo: print("Launching gradio!") with gr.Row():