Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UI to show more information about the reason of error #21

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ env/
*.swo
*.pyc
.DS_Store

# flagged folder
flagged/
11 changes: 7 additions & 4 deletions project_explainer_ui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
from gh_explainer import Explainer

def summarize(summarization_type, github_project_url, github_project_branch="main", huggingface_model_id="gpt2"):
gptExplainer = Explainer(huggingface_model_id)
if summarization_type == "brief":
return gptExplainer.brief(github_url=github_project_url, branch=github_project_branch)["summary"]
return gptExplainer.outline(github_url=github_project_url, branch=github_project_branch)["summary"]
try:
gptExplainer = Explainer(huggingface_model_id)
if summarization_type == "brief":
return gptExplainer.brief(github_url=github_project_url, branch=github_project_branch)["summary"]
return gptExplainer.outline(github_url=github_project_url, branch=github_project_branch)["summary"]
except Exception as e:
return f"An error occurred: {str(e)}"

demo = gr.Interface(
fn=summarize,
Expand Down
13 changes: 12 additions & 1 deletion project_processor/gh_processor/github_downloader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from git import Repo
from git import Repo, GitCommandError
import os

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -27,6 +27,17 @@ def download_github_repo(repo_url: str, branch: str = "main") -> str:
"""
repo_name = repo_url.split("/")[-1].split(".")[0]
repo_path = os.path.abspath(repo_name)
try:
Repo.clone_from(repo_url, repo_name, branch=branch)
except GitCommandError as e:
error_msg = str(e)
if "fatal: destination path" in error_msg and "already exists" in error_msg:
error_msg = f"The repository '{repo_name}' already exists on your system."
elif "exit code(128)" in error_msg:
error_msg = "Failed to clone the repository. Please check if the repository URL and branch are correct."
else:
error_msg = f"{error_msg}"
raise Exception(error_msg)

Repo.clone_from(repo_url, repo_name, branch=branch)

Expand Down