Spaces:
Sleeping
Sleeping
added fallback
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ _dist_cache: dict = {}
|
|
| 22 |
def _ensure_data():
|
| 23 |
if not os.path.exists(DATA_PATH):
|
| 24 |
from huggingface_hub import hf_hub_download
|
| 25 |
-
from huggingface_hub.
|
| 26 |
os.makedirs(_DATA_DIR, exist_ok=True)
|
| 27 |
filename = os.path.basename(DATA_PATH)
|
| 28 |
print(f"Downloading {filename} from HF Hub...")
|
|
@@ -35,11 +35,11 @@ def _ensure_data():
|
|
| 35 |
local_dir_use_symlinks=False,
|
| 36 |
token=os.environ.get("HF_TOKEN"),
|
| 37 |
)
|
| 38 |
-
except EntryNotFoundError:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
|
| 44 |
|
| 45 |
def _get_dist(team: str) -> InningOutcomeDistribution:
|
|
|
|
| 22 |
def _ensure_data():
|
| 23 |
if not os.path.exists(DATA_PATH):
|
| 24 |
from huggingface_hub import hf_hub_download
|
| 25 |
+
from huggingface_hub.errors import EntryNotFoundError, RepositoryNotFoundError
|
| 26 |
os.makedirs(_DATA_DIR, exist_ok=True)
|
| 27 |
filename = os.path.basename(DATA_PATH)
|
| 28 |
print(f"Downloading {filename} from HF Hub...")
|
|
|
|
| 35 |
local_dir_use_symlinks=False,
|
| 36 |
token=os.environ.get("HF_TOKEN"),
|
| 37 |
)
|
| 38 |
+
except (EntryNotFoundError, RepositoryNotFoundError):
|
| 39 |
+
print(f"{filename} not found on HF Hub. Fetching from Baseball Savant...")
|
| 40 |
+
result = update_season_data()
|
| 41 |
+
if result["status"] != "ok":
|
| 42 |
+
raise RuntimeError(f"Auto-fetch failed: {result['message']}")
|
| 43 |
|
| 44 |
|
| 45 |
def _get_dist(team: str) -> InningOutcomeDistribution:
|