Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from datasets import load_dataset, get_dataset_split_names
|
4 |
-
from huggingface_hub import HfApi
|
5 |
import os
|
6 |
import pathlib
|
7 |
import uuid
|
@@ -33,7 +33,10 @@ def get_user_datasets(username: str):
|
|
33 |
if not username:
|
34 |
return gr.Dropdown.update(choices=[], value=None, interactive=False)
|
35 |
try:
|
36 |
-
|
|
|
|
|
|
|
37 |
dataset_ids = [d.id for d in datasets if not d.private]
|
38 |
return gr.Dropdown.update(choices=sorted(dataset_ids), value=None, interactive=True)
|
39 |
except Exception as e:
|
@@ -61,7 +64,7 @@ def get_split_columns(dataset_id: str, split: str):
|
|
61 |
first_row = next(iter(dataset_sample))
|
62 |
columns = list(first_row.keys())
|
63 |
# Heuristically find the best text column
|
64 |
-
preferred_cols = ['text', 'content', 'instruction', 'question', 'document']
|
65 |
best_col = next((col for col in preferred_cols if col in columns), columns[0] if columns else None)
|
66 |
return gr.Dropdown.update(choices=columns, value=best_col, interactive=True)
|
67 |
except Exception as e:
|
@@ -130,8 +133,6 @@ def generate_atlas(
|
|
130 |
mount_path = f"/{uuid.uuid4().hex}"
|
131 |
atlas_app = make_server(atlas_dataset, static_path=static_path, duckdb_uri="wasm")
|
132 |
|
133 |
-
# --- THIS IS THE FIX ---
|
134 |
-
# Call mount_gradio_app on the Blocks instance `app`
|
135 |
app.mount_gradio_app(atlas_app, path=mount_path)
|
136 |
|
137 |
progress(1.0, desc="Done!")
|
@@ -199,6 +200,4 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Embedding Atlas Explorer") as app:
|
|
199 |
app.load(fn=get_user_datasets, inputs=[hf_user_input], outputs=[dataset_input])
|
200 |
|
201 |
if __name__ == "__main__":
|
202 |
-
# To run locally, you might need to log in to Hugging Face Hub
|
203 |
-
# HfFolder.save_token("YOUR_HF_TOKEN")
|
204 |
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from datasets import load_dataset, get_dataset_split_names
|
4 |
+
from huggingface_hub import HfApi
|
5 |
import os
|
6 |
import pathlib
|
7 |
import uuid
|
|
|
33 |
if not username:
|
34 |
return gr.Dropdown.update(choices=[], value=None, interactive=False)
|
35 |
try:
|
36 |
+
# --- THIS IS THE FIX ---
|
37 |
+
# Replace deprecated 'cardData=True' with 'full=True'
|
38 |
+
datasets = hf_api.list_datasets(author=username, full=True)
|
39 |
+
|
40 |
dataset_ids = [d.id for d in datasets if not d.private]
|
41 |
return gr.Dropdown.update(choices=sorted(dataset_ids), value=None, interactive=True)
|
42 |
except Exception as e:
|
|
|
64 |
first_row = next(iter(dataset_sample))
|
65 |
columns = list(first_row.keys())
|
66 |
# Heuristically find the best text column
|
67 |
+
preferred_cols = ['text', 'content', 'instruction', 'question', 'document', 'prompt']
|
68 |
best_col = next((col for col in preferred_cols if col in columns), columns[0] if columns else None)
|
69 |
return gr.Dropdown.update(choices=columns, value=best_col, interactive=True)
|
70 |
except Exception as e:
|
|
|
133 |
mount_path = f"/{uuid.uuid4().hex}"
|
134 |
atlas_app = make_server(atlas_dataset, static_path=static_path, duckdb_uri="wasm")
|
135 |
|
|
|
|
|
136 |
app.mount_gradio_app(atlas_app, path=mount_path)
|
137 |
|
138 |
progress(1.0, desc="Done!")
|
|
|
200 |
app.load(fn=get_user_datasets, inputs=[hf_user_input], outputs=[dataset_input])
|
201 |
|
202 |
if __name__ == "__main__":
|
|
|
|
|
203 |
app.launch()
|