Update app.py
Browse files
app.py
CHANGED
@@ -18,6 +18,17 @@ async def get_splits(dataset_name: str) -> Dict[str, List[Dict]]:
|
|
18 |
}
|
19 |
|
20 |
async def get_valid_datasets() -> List[str]:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
URL = f"https://huggingface.co/api/datasets"
|
22 |
async with httpx.AsyncClient() as session:
|
23 |
response = await session.get(URL)
|
|
|
18 |
}
|
19 |
|
20 |
async def get_valid_datasets() -> List[str]:
|
21 |
+
URL = f"https://huggingface.co/api/datasets"
|
22 |
+
async with httpx.AsyncClient() as session:
|
23 |
+
response = await session.get(URL)
|
24 |
+
try:
|
25 |
+
datasets_raw = response.text.split(",")
|
26 |
+
datasets = [dataset.strip() for dataset in datasets_raw if "/" in dataset]
|
27 |
+
except (KeyError, json.JSONDecodeError):
|
28 |
+
datasets = [] # Set a default value if the response is not in the expected format
|
29 |
+
return datasets
|
30 |
+
|
31 |
+
async def get_valid_datasets_old() -> List[str]:
|
32 |
URL = f"https://huggingface.co/api/datasets"
|
33 |
async with httpx.AsyncClient() as session:
|
34 |
response = await session.get(URL)
|