File tree Expand file tree Collapse file tree
src/snakemake_storage_plugin_cached_http Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ dev = [
7171
7272[tool .basedpyright ]
7373reportImplicitStringConcatenation = false
74- ignore = [" tests" ]
74+ ignore = [" tests" , " src/snakemake_storage_plugin_cached_http/monkeypatch.py " ]
7575reportUnusedCallResult = false
7676reportAny = false
7777reportMissingTypeStubs = false
Original file line number Diff line number Diff line change 3737from tqdm_loggable .auto import tqdm
3838from typing_extensions import override
3939
40+ from . import monkeypatch # noqa: F401
4041from .cache import Cache
4142
4243logger = get_logger ()
Original file line number Diff line number Diff line change 1+ # SPDX-FileCopyrightText: Contributors to PyPSA-Eur <https://github.com/pypsa/pypsa-eur>
2+ #
3+ # SPDX-License-Identifier: MIT
4+
5+ """
6+ Warn if snakemake-storage-plugin-http is installed and patch it to refuse all URLs.
7+
8+ Since cached-http now accepts all HTTP(S) URLs, having snakemake-storage-plugin-http
9+ installed at the same time causes Snakemake to raise "Multiple suitable storage
10+ providers found". This module detects that situation, warns the user, and patches the
11+ HTTP plugin to refuse every URL so that cached-http wins unconditionally.
12+ """
13+
14+ import warnings
15+
16+ from snakemake_interface_storage_plugins .storage_provider import (
17+ StorageQueryValidationResult ,
18+ )
19+
20+ try :
21+ import snakemake_storage_plugin_http
22+
23+ warnings .warn (
24+ "snakemake-storage-plugin-http is installed alongside "
25+ "snakemake-storage-plugin-cached-http. Because cached-http from v0.5 handles "
26+ "all HTTP(S) URLs, the http plugin has been disabled for this session. "
27+ "Please uninstall snakemake-storage-plugin-http. "
28+ "This compatibility shim will be removed in v0.6." ,
29+ FutureWarning ,
30+ )
31+
32+ snakemake_storage_plugin_http .StorageProvider .is_valid_query = classmethod (
33+ lambda c , q : StorageQueryValidationResult (
34+ query = q ,
35+ valid = False ,
36+ reason = "Disabled: snakemake-storage-plugin-cached-http handles all HTTP(S) URLs" ,
37+ )
38+ )
39+ except ImportError :
40+ pass
You can’t perform that action at this time.
0 commit comments