Joffrey Thomas commited on
Commit ·
bc48a86
1
Parent(s): bd692c9
change app
Browse files- data_manager.py +2 -8
- requirements.txt +3 -3
data_manager.py
CHANGED
|
@@ -3,11 +3,7 @@ import json
|
|
| 3 |
import tempfile
|
| 4 |
from datetime import datetime, timezone
|
| 5 |
from huggingface_hub import hf_hub_download, upload_file
|
| 6 |
-
|
| 7 |
-
from huggingface_hub.errors import HfHubHTTPError, EntryNotFoundError
|
| 8 |
-
except ImportError:
|
| 9 |
-
from huggingface_hub.utils import HfHubHTTPError
|
| 10 |
-
EntryNotFoundError = None
|
| 11 |
|
| 12 |
# Constant for the dataset repository, configurable via environment variable
|
| 13 |
DATASET_REPO = os.getenv("HF_DATASET_REPO", "Jofthomas/geoguessr_game_of_the_day")
|
|
@@ -34,10 +30,8 @@ def get_todays_games(token: str) -> list:
|
|
| 34 |
)
|
| 35 |
with open(local_path, "r", encoding="utf-8") as f:
|
| 36 |
return json.load(f)
|
| 37 |
-
except EntryNotFoundError:
|
| 38 |
-
return [] # No games played today yet, which is normal (file doesn't exist).
|
| 39 |
except HfHubHTTPError as e:
|
| 40 |
-
if
|
| 41 |
return [] # No games played today yet, which is normal.
|
| 42 |
else:
|
| 43 |
print(f"Error downloading daily records: {e}")
|
|
|
|
| 3 |
import tempfile
|
| 4 |
from datetime import datetime, timezone
|
| 5 |
from huggingface_hub import hf_hub_download, upload_file
|
| 6 |
+
from huggingface_hub.utils import HfHubHTTPError
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Constant for the dataset repository, configurable via environment variable
|
| 9 |
DATASET_REPO = os.getenv("HF_DATASET_REPO", "Jofthomas/geoguessr_game_of_the_day")
|
|
|
|
| 30 |
)
|
| 31 |
with open(local_path, "r", encoding="utf-8") as f:
|
| 32 |
return json.load(f)
|
|
|
|
|
|
|
| 33 |
except HfHubHTTPError as e:
|
| 34 |
+
if e.response.status_code == 404:
|
| 35 |
return [] # No games played today yet, which is normal.
|
| 36 |
else:
|
| 37 |
print(f"Error downloading daily records: {e}")
|
requirements.txt
CHANGED
|
@@ -2,9 +2,9 @@ Flask
|
|
| 2 |
python-dotenv
|
| 3 |
requests
|
| 4 |
mcp[cli]
|
| 5 |
-
huggingface_hub>=
|
| 6 |
-
transformers[mistral-common]>=
|
| 7 |
-
gradio
|
| 8 |
torch
|
| 9 |
sentencepiece
|
| 10 |
spaces
|
|
|
|
| 2 |
python-dotenv
|
| 3 |
requests
|
| 4 |
mcp[cli]
|
| 5 |
+
huggingface_hub>=0.25.0,<1.0
|
| 6 |
+
transformers[mistral-common]>=4.49.0,<5.0
|
| 7 |
+
gradio
|
| 8 |
torch
|
| 9 |
sentencepiece
|
| 10 |
spaces
|