Spaces:
Runtime error
Runtime error
File size: 2,028 Bytes
72d7898 f7c63a7 0921933 72d7898 f7c63a7 0921933 f7c63a7 0921933 6d9bc02 0921933 f7c63a7 72d7898 0921933 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# Import necessary libraries
import gradio as gr
from typing import Dict, Any
from data_loader import read_dask_data, read_polars_data, read_another_dask_data
# Function to handle the data loading and processing logic
def load_and_process_data(dataset_choice: str, num_rows: int) -> Dict[str, Any]:
try:
# Load and process datasets based on user choice
if dataset_choice == "Dask Data":
data = read_dask_data()
processed_data = data.head(num_rows)
elif dataset_choice == "Polars Data":
data = read_polars_data()
processed_data = data.head(num_rows)
elif dataset_choice == "Another Dask Data":
data = read_another_dask_data()
processed_data = data.head(num_rows)
else:
return {"error": "Invalid dataset choice."}
# Optionally, include more complex data processing here
# Return the processed data
return {
"Processed Data": processed_data
}
except Exception as e:
# Log the exception
print(f"Error processing data: {str(e)}")
return {"error": "Unable to process data. Please check the logs for details."}
# Create a Gradio interface with more features
def create_interface():
# Interface inputs
dataset_choice = gr.inputs.Dropdown(["Dask Data", "Polars Data", "Another Dask Data"], label="Select Dataset")
num_rows = gr.inputs.Slider(minimum=1, maximum=100, default=5, label="Number of Rows to Display")
# Interface definition
demo = gr.Interface(
fn=load_and_process_data,
inputs=[dataset_choice, num_rows], # User can select dataset and number of rows
outputs="json", # Display output as JSON
title="Enhanced Dataset Loader Demo",
description="Interact with various datasets and select the amount of data to display.",
allow_flagging="never" # Disable flagging if not needed
)
demo.launch()
if __name__ == "__main__":
create_interface()
|