Commit
·
a9b2499
1
Parent(s):
38d03f2
improved displaying representations
Browse files- gradio_tabs.py +8 -5
gradio_tabs.py
CHANGED
@@ -7,6 +7,7 @@ import gradio as gr
|
|
7 |
|
8 |
def display_representations(repos_df, repo, representation1, representation2):
|
9 |
repo_data = repos_df[repos_df["repo_name"] == repo]
|
|
|
10 |
logging.info(f"repo_data: {repo_data}")
|
11 |
text1 = (
|
12 |
repo_data[repo_data["representation"] == representation1]["text"].iloc[0]
|
@@ -19,7 +20,7 @@ def display_representations(repos_df, repo, representation1, representation2):
|
|
19 |
else "No data available"
|
20 |
)
|
21 |
|
22 |
-
return text1, text2
|
23 |
|
24 |
|
25 |
def get_representation_wordclouds(representations, repos_df):
|
@@ -60,6 +61,7 @@ def setup_repository_representations_tab(repos_df, repos, representation_types):
|
|
60 |
value="code2doc_generated_readme",
|
61 |
)
|
62 |
|
|
|
63 |
with gr.Row():
|
64 |
with gr.Column(
|
65 |
elem_id="column1",
|
@@ -77,24 +79,25 @@ def setup_repository_representations_tab(repos_df, repos, representation_types):
|
|
77 |
text2 = gr.Markdown()
|
78 |
|
79 |
def update_representations(repo, representation1, representation2):
|
80 |
-
text1_content, text2_content = display_representations(
|
81 |
repos_df, repo, representation1, representation2
|
82 |
)
|
83 |
return (
|
|
|
84 |
f"### Representation 1: {representation1}\n\n{text1_content}",
|
85 |
f"### Representation 2: {representation2}\n\n{text2_content}",
|
86 |
)
|
87 |
|
88 |
# Initial call to populate textboxes with default values
|
89 |
-
text1.value, text2.value = update_representations(
|
90 |
-
repos[0], "readme", "
|
91 |
)
|
92 |
|
93 |
for component in [repo, representation1, representation2]:
|
94 |
component.change(
|
95 |
fn=update_representations,
|
96 |
inputs=[repo, representation1, representation2],
|
97 |
-
outputs=[text1, text2],
|
98 |
)
|
99 |
|
100 |
|
|
|
7 |
|
8 |
def display_representations(repos_df, repo, representation1, representation2):
|
9 |
repo_data = repos_df[repos_df["repo_name"] == repo]
|
10 |
+
tasks = repo_data["tasks"].iloc[0]
|
11 |
logging.info(f"repo_data: {repo_data}")
|
12 |
text1 = (
|
13 |
repo_data[repo_data["representation"] == representation1]["text"].iloc[0]
|
|
|
20 |
else "No data available"
|
21 |
)
|
22 |
|
23 |
+
return tasks, text1, text2
|
24 |
|
25 |
|
26 |
def get_representation_wordclouds(representations, repos_df):
|
|
|
61 |
value="code2doc_generated_readme",
|
62 |
)
|
63 |
|
64 |
+
displayed_tasks = gr.Markdown(elem_id="tasks")
|
65 |
with gr.Row():
|
66 |
with gr.Column(
|
67 |
elem_id="column1",
|
|
|
79 |
text2 = gr.Markdown()
|
80 |
|
81 |
def update_representations(repo, representation1, representation2):
|
82 |
+
tasks, text1_content, text2_content = display_representations(
|
83 |
repos_df, repo, representation1, representation2
|
84 |
)
|
85 |
return (
|
86 |
+
"## Repository PapersWithCode tasks:\n" + ", ".join(tasks),
|
87 |
f"### Representation 1: {representation1}\n\n{text1_content}",
|
88 |
f"### Representation 2: {representation2}\n\n{text2_content}",
|
89 |
)
|
90 |
|
91 |
# Initial call to populate textboxes with default values
|
92 |
+
displayed_tasks.value, text1.value, text2.value = update_representations(
|
93 |
+
repos[0], "readme", "code2doc_generated_readme"
|
94 |
)
|
95 |
|
96 |
for component in [repo, representation1, representation2]:
|
97 |
component.change(
|
98 |
fn=update_representations,
|
99 |
inputs=[repo, representation1, representation2],
|
100 |
+
outputs=[displayed_tasks, text1, text2],
|
101 |
)
|
102 |
|
103 |
|