Commit
·
39e83f7
1
Parent(s):
58cf812
newer gradio version components
Browse files
app.py
CHANGED
@@ -34,61 +34,63 @@ def display_representations(repo, representation1, representation2):
|
|
34 |
return text1, text2
|
35 |
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
# Initial call to populate textboxes with default values
|
83 |
-
text1.value, text2.value = update_representations(
|
84 |
-
repos[0], "readme", "generated_readme"
|
85 |
)
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
93 |
|
94 |
-
|
|
|
34 |
return text1, text2
|
35 |
|
36 |
|
37 |
+
## main
|
38 |
+
repos_df = load_repo_df()
|
39 |
+
repos = list(repos_df["repo_name"].unique())
|
40 |
+
representation_types = list(repos_df["representation"].unique())
|
41 |
+
logging.info(f"found {len(repos)} repositories")
|
42 |
+
logging.info(f"representation types: {representation_types}")
|
43 |
+
|
44 |
+
with gr.Blocks() as demo:
|
45 |
+
gr.Markdown("# Repository Representations Viewer")
|
46 |
+
gr.Markdown("Select a repository and two representation types to compare them.")
|
47 |
+
|
48 |
+
with gr.Row():
|
49 |
+
repo = gr.Dropdown(choices=repos, label="Repository", value=repos[0])
|
50 |
+
representation1 = gr.Dropdown(
|
51 |
+
choices=representation_types, label="Representation 1", value="readme"
|
52 |
+
)
|
53 |
+
representation2 = gr.Dropdown(
|
54 |
+
choices=representation_types,
|
55 |
+
label="Representation 2",
|
56 |
+
value="generated_readme",
|
57 |
+
)
|
58 |
+
|
59 |
+
with gr.Row():
|
60 |
+
with gr.Column(
|
61 |
+
elem_id="column1",
|
62 |
+
variant="panel",
|
63 |
+
scale=1,
|
64 |
+
min_width=300,
|
65 |
+
):
|
66 |
+
text1 = gr.Markdown()
|
67 |
+
with gr.Column(
|
68 |
+
elem_id="column2",
|
69 |
+
variant="panel",
|
70 |
+
scale=1,
|
71 |
+
min_width=300,
|
72 |
+
):
|
73 |
+
text2 = gr.Markdown()
|
74 |
+
|
75 |
+
def update_representations(repo, representation1, representation2):
|
76 |
+
text1_content, text2_content = display_representations(
|
77 |
+
repo, representation1, representation2
|
78 |
+
)
|
79 |
+
return (
|
80 |
+
f"### Representation 1: {representation1}\n\n{text1_content}",
|
81 |
+
f"### Representation 2: {representation2}\n\n{text2_content}",
|
|
|
|
|
|
|
82 |
)
|
83 |
|
84 |
+
# Initial call to populate textboxes with default values
|
85 |
+
text1.value, text2.value = update_representations(
|
86 |
+
repos[0], "readme", "generated_readme"
|
87 |
+
)
|
88 |
+
|
89 |
+
for component in [repo, representation1, representation2]:
|
90 |
+
component.change(
|
91 |
+
fn=update_representations,
|
92 |
+
inputs=[repo, representation1, representation2],
|
93 |
+
outputs=[text1, text2],
|
94 |
+
)
|
95 |
|
96 |
+
demo.launch()
|