Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -23,34 +23,35 @@ def load_and_process_data(dataset_choice: str, num_rows: int) -> Dict[str, Any]:
|
|
23 |
processed_data = data.head(num_rows)
|
24 |
|
25 |
return {
|
26 |
-
"
|
27 |
}
|
28 |
except Exception as e:
|
29 |
# Log the exception
|
30 |
print(f"Error processing data: {str(e)}")
|
31 |
return {"error": "Unable to process data. Please check the logs for details."}
|
32 |
|
33 |
-
# Create a Gradio interface with
|
34 |
def create_interface():
|
35 |
-
# Interface inputs
|
36 |
-
dataset_choice = gr.Dropdown(
|
37 |
choices=["Dask Data", "Polars Data", "Another Dask Data"],
|
38 |
label="Select Dataset"
|
39 |
)
|
40 |
-
num_rows = gr.Slider(
|
41 |
-
minimum=1, maximum=100,
|
42 |
)
|
43 |
|
44 |
# Interface definition
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
54 |
demo.launch()
|
55 |
|
56 |
if __name__ == "__main__":
|
|
|
23 |
processed_data = data.head(num_rows)
|
24 |
|
25 |
return {
|
26 |
+
"processed_data": processed_data.to_dict() # Convert DataFrame to dictionary for JSON serialization
|
27 |
}
|
28 |
except Exception as e:
|
29 |
# Log the exception
|
30 |
print(f"Error processing data: {str(e)}")
|
31 |
return {"error": "Unable to process data. Please check the logs for details."}
|
32 |
|
33 |
+
# Create a Gradio interface with updated components
|
34 |
def create_interface():
|
35 |
+
# Interface inputs
|
36 |
+
dataset_choice = gr.components.Dropdown(
|
37 |
choices=["Dask Data", "Polars Data", "Another Dask Data"],
|
38 |
label="Select Dataset"
|
39 |
)
|
40 |
+
num_rows = gr.components.Slider(
|
41 |
+
minimum=1, maximum=100, value=5, label="Number of Rows to Display"
|
42 |
)
|
43 |
|
44 |
# Interface definition
|
45 |
+
with gr.Blocks() as demo:
|
46 |
+
gr.Markdown("# Enhanced Dataset Loader Demo")
|
47 |
+
gr.Markdown("Interact with various datasets and select the amount of data to display.")
|
48 |
+
with gr.Row():
|
49 |
+
dataset_choice.render()
|
50 |
+
num_rows.render()
|
51 |
+
processed_data_output = gr.JSON(label="Processed Data")
|
52 |
+
processed_data_output.render()
|
53 |
+
|
54 |
+
demo.add(dataset_choice, num_rows, processed_data_output, load_and_process_data)
|
55 |
demo.launch()
|
56 |
|
57 |
if __name__ == "__main__":
|