Spaces:
Paused
Paused
Commit
•
4c88070
1
Parent(s):
716758b
Fix exception handling in get_summary function
Browse files
main.py
CHANGED
@@ -214,9 +214,13 @@ async def get_summary(dataset_id: str) -> str | None:
|
|
214 |
|
215 |
try:
|
216 |
# dataset_id = request.dataset_id
|
217 |
-
|
218 |
-
|
219 |
-
|
|
|
|
|
|
|
|
|
220 |
card_text = card_text.text
|
221 |
card = DatasetCard(card_text)
|
222 |
text = card.text
|
@@ -225,7 +229,6 @@ async def get_summary(dataset_id: str) -> str | None:
|
|
225 |
return None
|
226 |
cache_key = f"predict:{dataset_id}"
|
227 |
cached_data = await cache.get(cache_key)
|
228 |
-
|
229 |
if cached_data is not None:
|
230 |
cached_summary, cached_last_modified_time = cached_data
|
231 |
# Get the current last modified time of the dataset
|
|
|
214 |
|
215 |
try:
|
216 |
# dataset_id = request.dataset_id
|
217 |
+
try:
|
218 |
+
card_text = await async_httpx_client.get(
|
219 |
+
f"https://huggingface.co/datasets/{dataset_id}/raw/main/README.md"
|
220 |
+
)
|
221 |
+
except Exception as e:
|
222 |
+
logger.error(e)
|
223 |
+
return None
|
224 |
card_text = card_text.text
|
225 |
card = DatasetCard(card_text)
|
226 |
text = card.text
|
|
|
229 |
return None
|
230 |
cache_key = f"predict:{dataset_id}"
|
231 |
cached_data = await cache.get(cache_key)
|
|
|
232 |
if cached_data is not None:
|
233 |
cached_summary, cached_last_modified_time = cached_data
|
234 |
# Get the current last modified time of the dataset
|