Spaces:
Paused
Paused
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -145,7 +145,7 @@ except ImportError as e:
|
|
| 145 |
print(f"Error importing TinyTroupe: {e}")
|
| 146 |
|
| 147 |
# Configuration from environment variables
|
| 148 |
-
GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN")
|
| 149 |
JULES_API_KEY = os.environ.get("JULES_API_KEY")
|
| 150 |
BLABLADOR_API_KEY = os.environ.get("BLABLADOR_API_KEY")
|
| 151 |
BLABLADOR_BASE_URL = "https://api.helmholtz-blablador.fz-juelich.de/v1"
|
|
@@ -601,16 +601,21 @@ def get_reports_in_branch(repo_full_name, branch_name):
|
|
| 601 |
contents = repo.get_contents("user_experience_reports", ref=branch_name)
|
| 602 |
reports = []
|
| 603 |
for content_file in contents:
|
| 604 |
-
|
| 605 |
-
|
|
|
|
|
|
|
|
|
|
| 606 |
return sorted(reports, reverse=True)
|
| 607 |
except Exception as e:
|
| 608 |
print(f"Error fetching reports in branch {branch_name}: {e}")
|
| 609 |
return []
|
| 610 |
|
| 611 |
def get_report_content(repo_full_name, branch_name, report_filename):
|
| 612 |
-
if not gh
|
| 613 |
-
return "Error:
|
|
|
|
|
|
|
| 614 |
try:
|
| 615 |
repo = gh.get_repo(repo_full_name)
|
| 616 |
file_content = repo.get_contents(f"user_experience_reports/{report_filename}", ref=branch_name)
|
|
@@ -658,12 +663,18 @@ def pull_report_from_pr(pr_url):
|
|
| 658 |
return f"Error pulling report: {str(e)}"
|
| 659 |
|
| 660 |
def render_slides(repo_full_name, branch_name, report_filename):
|
| 661 |
-
if not gh
|
| 662 |
-
return "Error:
|
|
|
|
|
|
|
| 663 |
|
| 664 |
try:
|
| 665 |
# report_filename is report_ID.md, we want slides_ID.md
|
| 666 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 667 |
|
| 668 |
repo = gh.get_repo(repo_full_name)
|
| 669 |
try:
|
|
@@ -783,6 +794,7 @@ with gr.Blocks() as demo:
|
|
| 783 |
reports = get_reports_in_branch(repo_name, branch_name)
|
| 784 |
return gr.update(choices=reports, value=reports[0] if reports else None)
|
| 785 |
|
|
|
|
| 786 |
rv_refresh_branches_btn.click(fn=rv_update_branches, inputs=[rv_repo_select], outputs=[rv_branch_select])
|
| 787 |
rv_branch_select.change(fn=rv_update_reports, inputs=[rv_repo_select, rv_branch_select], outputs=[rv_report_select])
|
| 788 |
rv_load_report_btn.click(fn=get_report_content, inputs=[rv_repo_select, rv_branch_select, rv_report_select], outputs=[rv_report_viewer])
|
|
@@ -809,6 +821,7 @@ with gr.Blocks() as demo:
|
|
| 809 |
reports = get_reports_in_branch(repo_name, branch_name)
|
| 810 |
return gr.update(choices=reports, value=reports[0] if reports else None)
|
| 811 |
|
|
|
|
| 812 |
sl_refresh_branches_btn.click(fn=sl_update_branches, inputs=[sl_repo_select], outputs=[sl_branch_select])
|
| 813 |
sl_branch_select.change(fn=sl_update_reports, inputs=[sl_repo_select, sl_branch_select], outputs=[sl_report_select])
|
| 814 |
sl_render_btn.click(fn=render_slides, inputs=[sl_repo_select, sl_branch_select, sl_report_select], outputs=[slideshow_display])
|
|
|
|
| 145 |
print(f"Error importing TinyTroupe: {e}")
|
| 146 |
|
| 147 |
# Configuration from environment variables
|
| 148 |
+
GITHUB_TOKEN = os.environ.get("GITHUB_TOKEN") or os.environ.get("GITHUB_API_TOKEN")
|
| 149 |
JULES_API_KEY = os.environ.get("JULES_API_KEY")
|
| 150 |
BLABLADOR_API_KEY = os.environ.get("BLABLADOR_API_KEY")
|
| 151 |
BLABLADOR_BASE_URL = "https://api.helmholtz-blablador.fz-juelich.de/v1"
|
|
|
|
| 601 |
contents = repo.get_contents("user_experience_reports", ref=branch_name)
|
| 602 |
reports = []
|
| 603 |
for content_file in contents:
|
| 604 |
+
name = content_file.name
|
| 605 |
+
if name == "report.md" or (name.startswith("report_") and name.endswith(".md")):
|
| 606 |
+
reports.append(name)
|
| 607 |
+
|
| 608 |
+
# Sort so that report_ID.md are grouped and report.md is visible
|
| 609 |
return sorted(reports, reverse=True)
|
| 610 |
except Exception as e:
|
| 611 |
print(f"Error fetching reports in branch {branch_name}: {e}")
|
| 612 |
return []
|
| 613 |
|
| 614 |
def get_report_content(repo_full_name, branch_name, report_filename):
|
| 615 |
+
if not gh:
|
| 616 |
+
return "Error: GitHub client not initialized. Check your token."
|
| 617 |
+
if not repo_full_name or not branch_name or not report_filename:
|
| 618 |
+
return "Please select a repository, branch, and report."
|
| 619 |
try:
|
| 620 |
repo = gh.get_repo(repo_full_name)
|
| 621 |
file_content = repo.get_contents(f"user_experience_reports/{report_filename}", ref=branch_name)
|
|
|
|
| 663 |
return f"Error pulling report: {str(e)}"
|
| 664 |
|
| 665 |
def render_slides(repo_full_name, branch_name, report_filename):
|
| 666 |
+
if not gh:
|
| 667 |
+
return "Error: GitHub client not initialized. Check your token."
|
| 668 |
+
if not repo_full_name or not branch_name or not report_filename:
|
| 669 |
+
return "Please select a repository, branch, and report."
|
| 670 |
|
| 671 |
try:
|
| 672 |
# report_filename is report_ID.md, we want slides_ID.md
|
| 673 |
+
# if report_filename is report.md, we want slides.md
|
| 674 |
+
if report_filename == "report.md":
|
| 675 |
+
slides_filename = "slides.md"
|
| 676 |
+
else:
|
| 677 |
+
slides_filename = report_filename.replace("report_", "slides_")
|
| 678 |
|
| 679 |
repo = gh.get_repo(repo_full_name)
|
| 680 |
try:
|
|
|
|
| 794 |
reports = get_reports_in_branch(repo_name, branch_name)
|
| 795 |
return gr.update(choices=reports, value=reports[0] if reports else None)
|
| 796 |
|
| 797 |
+
rv_repo_select.change(fn=rv_update_branches, inputs=[rv_repo_select], outputs=[rv_branch_select])
|
| 798 |
rv_refresh_branches_btn.click(fn=rv_update_branches, inputs=[rv_repo_select], outputs=[rv_branch_select])
|
| 799 |
rv_branch_select.change(fn=rv_update_reports, inputs=[rv_repo_select, rv_branch_select], outputs=[rv_report_select])
|
| 800 |
rv_load_report_btn.click(fn=get_report_content, inputs=[rv_repo_select, rv_branch_select, rv_report_select], outputs=[rv_report_viewer])
|
|
|
|
| 821 |
reports = get_reports_in_branch(repo_name, branch_name)
|
| 822 |
return gr.update(choices=reports, value=reports[0] if reports else None)
|
| 823 |
|
| 824 |
+
sl_repo_select.change(fn=sl_update_branches, inputs=[sl_repo_select], outputs=[sl_branch_select])
|
| 825 |
sl_refresh_branches_btn.click(fn=sl_update_branches, inputs=[sl_repo_select], outputs=[sl_branch_select])
|
| 826 |
sl_branch_select.change(fn=sl_update_reports, inputs=[sl_repo_select, sl_branch_select], outputs=[sl_report_select])
|
| 827 |
sl_render_btn.click(fn=render_slides, inputs=[sl_repo_select, sl_branch_select, sl_report_select], outputs=[slideshow_display])
|