Spaces:
Runtime error
Runtime error
fix update_columns
Browse files
app.py
CHANGED
|
@@ -122,22 +122,26 @@ def train_model(dataset_id, custom_dataset_id, label_column, feature_columns,
|
|
| 122 |
|
| 123 |
return output_text, fig, columns_available
|
| 124 |
|
| 125 |
-
def update_columns(dataset_id, custom_dataset_id):
|
| 126 |
"""
|
| 127 |
-
|
| 128 |
-
|
| 129 |
"""
|
| 130 |
if dataset_id != "SKIP/ENTER_CUSTOM":
|
| 131 |
final_id = dataset_id
|
|
|
|
| 132 |
else:
|
|
|
|
| 133 |
final_id = custom_dataset_id.strip()
|
|
|
|
| 134 |
|
| 135 |
-
# Try to load the dataset and return columns
|
| 136 |
try:
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
| 138 |
df = pd.DataFrame(ds)
|
| 139 |
cols = df.columns.tolist()
|
| 140 |
-
# Return as list of selectable options
|
| 141 |
return gr.update(choices=cols), gr.update(choices=cols), f"Columns found: {cols}"
|
| 142 |
except Exception as e:
|
| 143 |
return gr.update(choices=[]), gr.update(choices=[]), f"Error loading {final_id}: {e}"
|
|
|
|
| 122 |
|
| 123 |
return output_text, fig, columns_available
|
| 124 |
|
| 125 |
+
def update_columns(dataset_id, dataset_config, custom_dataset_id):
|
| 126 |
"""
|
| 127 |
+
Load the dataset from HF hub, using either the suggested one or the custom user-specified,
|
| 128 |
+
plus an optional config.
|
| 129 |
"""
|
| 130 |
if dataset_id != "SKIP/ENTER_CUSTOM":
|
| 131 |
final_id = dataset_id
|
| 132 |
+
final_config = dataset_config.strip() if dataset_config else None
|
| 133 |
else:
|
| 134 |
+
# Use the user-supplied text
|
| 135 |
final_id = custom_dataset_id.strip()
|
| 136 |
+
final_config = None # or parse from text if you like
|
| 137 |
|
|
|
|
| 138 |
try:
|
| 139 |
+
if final_config:
|
| 140 |
+
ds = load_dataset(final_id, final_config, split="train")
|
| 141 |
+
else:
|
| 142 |
+
ds = load_dataset(final_id, split="train")
|
| 143 |
df = pd.DataFrame(ds)
|
| 144 |
cols = df.columns.tolist()
|
|
|
|
| 145 |
return gr.update(choices=cols), gr.update(choices=cols), f"Columns found: {cols}"
|
| 146 |
except Exception as e:
|
| 147 |
return gr.update(choices=[]), gr.update(choices=[]), f"Error loading {final_id}: {e}"
|