|
19 | 19 | from openml.__version__ import __version__ |
20 | 20 | from openml.enums import RetryPolicy |
21 | 21 | from openml.exceptions import ( |
22 | | - OpenMLCacheRequiredError, |
23 | 22 | OpenMLHashException, |
24 | 23 | OpenMLNotAuthorizedError, |
25 | 24 | OpenMLServerError, |
@@ -231,7 +230,7 @@ def __init__( # noqa: PLR0913 |
231 | 230 | api_key: str, |
232 | 231 | retries: int, |
233 | 232 | retry_policy: RetryPolicy, |
234 | | - cache: HTTPCache | None = None, |
| 233 | + cache: HTTPCache, |
235 | 234 | ) -> None: |
236 | 235 | self.server = server |
237 | 236 | self.base_url = base_url |
@@ -608,7 +607,7 @@ def request( # noqa: PLR0913, C901 |
608 | 607 |
|
609 | 608 | files = request_kwargs.pop("files", None) |
610 | 609 |
|
611 | | - if use_cache and not reset_cache and self.cache is not None: |
| 610 | + if use_cache and not reset_cache: |
612 | 611 | cache_key = self.cache.get_key(url, params) |
613 | 612 | try: |
614 | 613 | return self.cache.load(cache_key) |
@@ -647,7 +646,7 @@ def request( # noqa: PLR0913, C901 |
647 | 646 | if md5_checksum is not None: |
648 | 647 | self._verify_checksum(response, md5_checksum) |
649 | 648 |
|
650 | | - if use_cache and self.cache is not None: |
| 649 | + if use_cache: |
651 | 650 | cache_key = self.cache.get_key(url, params) |
652 | 651 | self.cache.save(cache_key, response) |
653 | 652 |
|
@@ -812,15 +811,9 @@ def download( |
812 | 811 |
|
813 | 812 | Raises |
814 | 813 | ------ |
815 | | - OpenMLCacheRequiredError |
816 | | - If no cache instance is configured. |
817 | 814 | OpenMLHashException |
818 | 815 | If checksum verification fails. |
819 | 816 | """ |
820 | | - if self.cache is None: |
821 | | - raise OpenMLCacheRequiredError( |
822 | | - "A cache object is required for download, but none was provided in the HTTPClient." |
823 | | - ) |
824 | 817 | base = self.cache.path |
825 | 818 | file_path = base / "downloads" / urlparse(url).path.lstrip("/") / file_name |
826 | 819 | file_path = file_path.expanduser() |
|
0 commit comments