Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -31,14 +31,14 @@ hf_api = HfApi()
|
|
31 |
def get_user_datasets(username: str):
|
32 |
"""Fetches all public datasets for a given username or organization."""
|
33 |
if not username:
|
34 |
-
return gr.
|
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.
|
42 |
except Exception as e:
|
43 |
gr.Warning(f"Could not fetch datasets for user '{username}'. Error: {e}")
|
44 |
return gr.update(choices=[], value=None, interactive=False)
|
@@ -46,10 +46,10 @@ def get_user_datasets(username: str):
|
|
46 |
def get_dataset_splits(dataset_id: str):
|
47 |
"""Gets all available splits for a selected dataset."""
|
48 |
if not dataset_id:
|
49 |
-
return gr.
|
50 |
try:
|
51 |
splits = get_dataset_split_names(dataset_id)
|
52 |
-
return gr.
|
53 |
except Exception as e:
|
54 |
gr.Warning(f"Could not fetch splits for dataset '{dataset_id}'. Error: {e}")
|
55 |
return gr.update(choices=[], value=None, interactive=False)
|
|
|
31 |
def get_user_datasets(username: str):
|
32 |
"""Fetches all public datasets for a given username or organization."""
|
33 |
if not username:
|
34 |
+
return gr.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.update(choices=sorted(dataset_ids), value=None, interactive=True)
|
42 |
except Exception as e:
|
43 |
gr.Warning(f"Could not fetch datasets for user '{username}'. Error: {e}")
|
44 |
return gr.update(choices=[], value=None, interactive=False)
|
|
|
46 |
def get_dataset_splits(dataset_id: str):
|
47 |
"""Gets all available splits for a selected dataset."""
|
48 |
if not dataset_id:
|
49 |
+
return gr.update(choices=[], value=None, interactive=False)
|
50 |
try:
|
51 |
splits = get_dataset_split_names(dataset_id)
|
52 |
+
return gr.update(choices=splits, value=splits[0] if splits else None, interactive=True)
|
53 |
except Exception as e:
|
54 |
gr.Warning(f"Could not fetch splits for dataset '{dataset_id}'. Error: {e}")
|
55 |
return gr.update(choices=[], value=None, interactive=False)
|