Skip to content

Commit

Permalink
Add headers to download queries to workaround readthedocs/readthedocs…
Browse files Browse the repository at this point in the history
  • Loading branch information
znichollscr committed Nov 26, 2024
1 parent 2023b84 commit ea27ea9
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/input4mips_validation/cvs/loading_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ class RawCVLoaderKnownRemoteRegistry:
Whether to force a new download of the file if it already exists
"""

def load_raw(self, filename: str) -> str:
def load_raw(
self, filename: str, downloader: pooch.HTTPDownloader | None = None
) -> str:
"""
Load raw CV data
Expand All @@ -122,6 +124,11 @@ def load_raw(self, filename: str) -> str:
filename
Filename from which to load raw CV data
downloader
Downloader to use when fetching.
If not supplied, we use a basic default HTTP downloader.
Returns
-------
Raw CV data
Expand All @@ -131,7 +138,13 @@ def load_raw(self, filename: str) -> str:
if expected_out_file.exists():
expected_out_file.unlink()

with open(Path(self.registry.fetch(filename))) as fh:
if downloader is None:
downloader = pooch.HTTPDownloader(
# https://github.com/readthedocs/readthedocs.org/issues/11763
headers={"User-Agent": "input4mips-validation"}
)

with open(Path(self.registry.fetch(filename, downloader=downloader))) as fh:
raw = fh.read()

return raw
Expand Down

0 comments on commit ea27ea9

Please sign in to comment.