Skip to content

Commit 00009d2

Browse files
committed
chore: Fetch the URL first
1 parent 4ceb13f commit 00009d2

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

pixi.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ xcdat = ">=0.9.1,<0.10"
2727
xesmf = ">=0.8.10,<0.9"
2828
joblib = ">=1.5.2,<2"
2929
loguru = ">=0.7.3,<0.8"
30+
requests = ">=2.32.5,<3"
3031

3132
[tool.pixi.pypi-dependencies]
3233
# Add any dependencies that aren't available on conda-forge here

src/ref_sample_data/data_request/obs4ref.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os
22
import pathlib
3+
import tempfile
34
from pathlib import Path
45

56
import pandas as pd
67
import pooch
8+
import requests
79
import xarray as xr
810

911
from ref_sample_data.data_request.base import DecimateMixin
@@ -45,10 +47,15 @@ def fetch_datasets(self) -> pd.DataFrame:
4547
retry_if_failed=10,
4648
env="REF_DATASET_CACHE_DIR",
4749
)
48-
registry.load_registry(
50+
registry_url = (
4951
f"https://raw.githubusercontent.com/Climate-REF/climate-ref/refs/heads/{self.branch_or_tag}"
5052
f"/packages/climate-ref/src/climate_ref/dataset_registry/obs4ref_reference.txt"
5153
)
54+
response = requests.get(registry_url, timeout=30)
55+
response.raise_for_status()
56+
with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as tmpfile:
57+
tmpfile.write(response.text)
58+
registry.load_registry(tmpfile.name)
5259

5360
datasets = []
5461
for key in registry.registry.keys():

0 commit comments

Comments
 (0)