Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,24 +6,24 @@ from data_loader import read_dask_data, read_polars_data, read_another_dask_data
|
|
6 |
# Function to handle the data loading and processing logic
|
7 |
def load_and_process_data(dataset_choice: str, num_rows: int) -> Dict[str, Any]:
|
8 |
try:
|
9 |
-
# Load
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
else:
|
20 |
return {"error": "Invalid dataset choice."}
|
21 |
|
22 |
-
#
|
|
|
|
|
23 |
|
24 |
-
# Return the processed data
|
25 |
return {
|
26 |
-
"Processed Data": processed_data
|
27 |
}
|
28 |
except Exception as e:
|
29 |
# Log the exception
|
@@ -32,9 +32,14 @@ def load_and_process_data(dataset_choice: str, num_rows: int) -> Dict[str, Any]:
|
|
32 |
|
33 |
# Create a Gradio interface with more features
|
34 |
def create_interface():
|
35 |
-
# Interface inputs
|
36 |
-
dataset_choice = gr.
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
# Interface definition
|
40 |
demo = gr.Interface(
|
|
|
6 |
# Function to handle the data loading and processing logic
|
7 |
def load_and_process_data(dataset_choice: str, num_rows: int) -> Dict[str, Any]:
|
8 |
try:
|
9 |
+
# Load datasets based on user choice
|
10 |
+
dataset_mapping = {
|
11 |
+
"Dask Data": read_dask_data,
|
12 |
+
"Polars Data": read_polars_data,
|
13 |
+
"Another Dask Data": read_another_dask_data
|
14 |
+
}
|
15 |
+
|
16 |
+
# Fetch the chosen dataset using the mapping
|
17 |
+
data_loader = dataset_mapping.get(dataset_choice)
|
18 |
+
if not data_loader:
|
|
|
19 |
return {"error": "Invalid dataset choice."}
|
20 |
|
21 |
+
# Process data to show the specified number of rows
|
22 |
+
data = data_loader()
|
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
|
|
|
32 |
|
33 |
# Create a Gradio interface with more features
|
34 |
def create_interface():
|
35 |
+
# Interface inputs (updated for Gradio v5.x)
|
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, default=5, label="Number of Rows to Display"
|
42 |
+
)
|
43 |
|
44 |
# Interface definition
|
45 |
demo = gr.Interface(
|