lambdaofgod commited on
Commit
39e83f7
·
1 Parent(s): 58cf812

newer gradio version components

Browse files
Files changed (1) hide show
  1. app.py +57 -55
app.py CHANGED
@@ -34,61 +34,63 @@ def display_representations(repo, representation1, representation2):
34
  return text1, text2
35
 
36
 
37
- if __name__ == "__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(*args):
76
- text1_content, text2_content = display_representations(*args)
77
- return (
78
- f"### Representation 1\n\n{text1_content}",
79
- f"### Representation 2\n\n{text2_content}",
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
- for component in [repo, representation1, representation2]:
88
- component.change(
89
- fn=update_representations,
90
- inputs=[repo, representation1, representation2],
91
- outputs=[text1, text2],
92
- )
 
 
 
 
 
93
 
94
- demo.launch()
 
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()