Skip to content

Commit

Permalink
work around blocked HTTP requests from RTD to github (#93)
Browse files Browse the repository at this point in the history
* set custom user agent

* [test-upstream]
  • Loading branch information
keewis authored Nov 15, 2024
1 parent 0820d4e commit f4a6b80
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion xdggs/tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def open_dataset(
--------
xarray.tutorial.open_dataset
"""
import xdggs

logger = pooch.get_logger()
logger.setLevel("WARNING")
Expand All @@ -109,8 +110,13 @@ def open_dataset(

url = f"{base_url}/raw/{version}/{name}/{path.name}"

headers = {"User-Agent": f"xdggs/{xdggs.__version__}"}

# retrieve the file
filepath = pooch.retrieve(url=url, known_hash=None, path=cache_dir)
downloader = pooch.HTTPDownloader(headers=headers)
filepath = pooch.retrieve(
url=url, known_hash=None, path=cache_dir, downloader=downloader
)
ds = _open_dataset(filepath, engine=engine, **kws)
if not cache:
ds = ds.load()
Expand Down

0 comments on commit f4a6b80

Please sign in to comment.