awacke1 commited on
Commit
b8d2d87
·
verified ·
1 Parent(s): 4e37f97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -22,7 +22,13 @@ async def get_valid_datasets() -> List[str]:
22
  async with httpx.AsyncClient() as session:
23
  response = await session.get(URL)
24
  try:
25
- datasets = [dataset["id"] for dataset in response.json() if "/" in dataset["id"]]
 
 
 
 
 
 
26
  except (KeyError, json.JSONDecodeError):
27
  datasets = [] # Set a default value if the response is not in the expected format
28
  return datasets
 
22
  async with httpx.AsyncClient() as session:
23
  response = await session.get(URL)
24
  try:
25
+ datasets_raw = response.json()
26
+ datasets = []
27
+ for dataset_raw in datasets_raw:
28
+ if isinstance(dataset_raw, str) and "/" in dataset_raw:
29
+ datasets.append(dataset_raw)
30
+ elif isinstance(dataset_raw, dict) and "/" in dataset_raw.get("id", ""):
31
+ datasets.append(dataset_raw["id"])
32
  except (KeyError, json.JSONDecodeError):
33
  datasets = [] # Set a default value if the response is not in the expected format
34
  return datasets