Spaces:
Sleeping
Sleeping
Ryan
commited on
Commit
·
b0473cc
1
Parent(s):
f358b3f
update
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from ui.dataset_input import create_dataset_input, load_example_dataset
|
3 |
-
from ui.analysis_screen import create_analysis_screen
|
4 |
|
5 |
def create_app():
|
6 |
"""
|
@@ -49,40 +49,49 @@ def create_app():
|
|
49 |
|
50 |
# Analysis Tab
|
51 |
with gr.Tab("Analysis"):
|
52 |
-
# Use create_analysis_screen
|
53 |
analysis_options, analysis_params, run_analysis_btn, analysis_output = create_analysis_screen()
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
# Define a helper function to extract parameter values and call process_analysis_request
|
56 |
-
def run_analysis(dataset, selected_analyses,
|
57 |
-
from ui.analysis_screen import process_analysis_request
|
58 |
-
|
59 |
# Check if dataset exists
|
60 |
if not dataset or "entries" not in dataset or not dataset["entries"]:
|
61 |
return {}, gr.update(visible=True, value={"error": "No dataset provided. Please create a dataset in the Dataset Input tab first."})
|
62 |
|
63 |
-
#
|
64 |
-
|
65 |
-
params = {}
|
66 |
-
|
67 |
-
# Get the bow_top value if Bag of Words is selected
|
68 |
-
if "Bag of Words" in selected_analyses:
|
69 |
-
# Get the slider value - in a real app, you'd need to find a more robust way to do this
|
70 |
-
# For now, we'll use the default value
|
71 |
-
params["bow_top"] = 25
|
72 |
|
73 |
# Call the process_analysis_request function with proper parameters
|
74 |
results, output = process_analysis_request(dataset, selected_analyses, params)
|
75 |
return results, output
|
76 |
|
77 |
-
# Run analysis with proper parameters
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
return app
|
85 |
|
86 |
if __name__ == "__main__":
|
87 |
app = create_app()
|
88 |
-
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from ui.dataset_input import create_dataset_input, load_example_dataset
|
3 |
+
from ui.analysis_screen import create_analysis_screen, process_analysis_request
|
4 |
|
5 |
def create_app():
|
6 |
"""
|
|
|
49 |
|
50 |
# Analysis Tab
|
51 |
with gr.Tab("Analysis"):
|
52 |
+
# Use create_analysis_screen to get UI components
|
53 |
analysis_options, analysis_params, run_analysis_btn, analysis_output = create_analysis_screen()
|
54 |
+
|
55 |
+
# Find the bow_top slider within analysis_params
|
56 |
+
# We directly access the bow_top slider using its name/element_id
|
57 |
+
bow_top_slider = None
|
58 |
+
for component in analysis_params.children:
|
59 |
+
if hasattr(component, 'children'):
|
60 |
+
for child in component.children:
|
61 |
+
if hasattr(child, 'elem_id') and child.elem_id == "bow_top_slider":
|
62 |
+
bow_top_slider = child
|
63 |
+
break
|
64 |
+
|
65 |
# Define a helper function to extract parameter values and call process_analysis_request
|
66 |
+
def run_analysis(dataset, selected_analyses, bow_top_value=25):
|
|
|
|
|
67 |
# Check if dataset exists
|
68 |
if not dataset or "entries" not in dataset or not dataset["entries"]:
|
69 |
return {}, gr.update(visible=True, value={"error": "No dataset provided. Please create a dataset in the Dataset Input tab first."})
|
70 |
|
71 |
+
# Create parameters dictionary with the slider value
|
72 |
+
params = {"bow_top": bow_top_value}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Call the process_analysis_request function with proper parameters
|
75 |
results, output = process_analysis_request(dataset, selected_analyses, params)
|
76 |
return results, output
|
77 |
|
78 |
+
# Run analysis with proper parameters - include the bow_top_slider directly
|
79 |
+
if bow_top_slider:
|
80 |
+
run_analysis_btn.click(
|
81 |
+
fn=run_analysis,
|
82 |
+
inputs=[dataset_state, analysis_options, bow_top_slider],
|
83 |
+
outputs=[analysis_results_state, analysis_output]
|
84 |
+
)
|
85 |
+
else:
|
86 |
+
# Fallback if slider wasn't found
|
87 |
+
run_analysis_btn.click(
|
88 |
+
fn=run_analysis,
|
89 |
+
inputs=[dataset_state, analysis_options],
|
90 |
+
outputs=[analysis_results_state, analysis_output]
|
91 |
+
)
|
92 |
|
93 |
return app
|
94 |
|
95 |
if __name__ == "__main__":
|
96 |
app = create_app()
|
97 |
+
app.launch()
|