From 85ea0a425ffdc23ad8ab3fb56d42c5c56170d7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20K=C3=BCderle?= Date: Thu, 14 Nov 2024 18:55:02 +0100 Subject: [PATCH] Attempt fix for download issue according to https://github.com/readthedocs/readthedocs.org/issues/11763 --- mobgap/data/validation_results.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mobgap/data/validation_results.py b/mobgap/data/validation_results.py index 374b6a0b..28191a32 100644 --- a/mobgap/data/validation_results.py +++ b/mobgap/data/validation_results.py @@ -12,6 +12,9 @@ class ValidationResultLoader: """Load the revalidation results either by downloading them or from a local folder.""" VALIDATION_REPO_DATA = "https://raw.githubusercontent.com/mobilise-d/mobgap_validation/{version}" + HTTP_HEADERS: Final = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36" + } CONDITION_INDEX_COLS: Final[dict[Literal["free_living", "laboratory"], list[str]]] = { "free_living": [ @@ -62,6 +65,10 @@ def _base_path(self) -> Union[Path, str]: return self.result_path / self.sub_folder return self.sub_folder + @property + def downloader(self): + return pooch.HTTPDownloader(headers=self.HTTP_HEADERS, progressbar=True) + def load_single_results(self, algo_name: str, condition: Literal["free_living", "laboratory"]) -> pd.DataFrame: """Load the results for a specific condition.""" if self.result_path is not None: @@ -72,8 +79,11 @@ def load_single_results(self, algo_name: str, condition: Literal["free_living", registry = pooch.retrieve( f"{self.VALIDATION_REPO_DATA.format(version=self.version)}/results_file_registry.txt", known_hash=None, + downloader=self.downloader, ) self.brian.load_registry(registry) return pd.read_csv( - self.brian.fetch(f"{self.sub_folder}/{condition}/{algo_name}/single_results.csv"), + self.brian.fetch( + f"{self.sub_folder}/{condition}/{algo_name}/single_results.csv", downloader=self.downloader + ), ).set_index(self.CONDITION_INDEX_COLS[condition])