Commit
·
4726829
1
Parent(s):
ef19caa
Refactor get_first_config_and_split_name function to handle exceptions
Browse files
app.py
CHANGED
|
@@ -52,10 +52,16 @@ def datasets_server_valid_rows(hub_id: str):
|
|
| 52 |
|
| 53 |
|
| 54 |
def get_first_config_and_split_name(hub_id: str):
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
|
| 61 |
def get_dataset_info(hub_id: str, config: str | None = None):
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
def get_first_config_and_split_name(hub_id: str):
|
| 55 |
+
try:
|
| 56 |
+
resp = client.get(
|
| 57 |
+
f"https://datasets-server.huggingface.co/splits?dataset={hub_id}"
|
| 58 |
+
)
|
| 59 |
+
|
| 60 |
+
data = resp.json()
|
| 61 |
+
return data["splits"][0]["config"], data["splits"][0]["split"]
|
| 62 |
+
except Exception as e:
|
| 63 |
+
logger.error(f"Failed to get splits for {hub_id}: {e}")
|
| 64 |
+
return None
|
| 65 |
|
| 66 |
|
| 67 |
def get_dataset_info(hub_id: str, config: str | None = None):
|