Skip to content

Commit fbccadb

Browse files
committed
Rename to snakemake-storage-plugin-cached-http
1 parent 9f3b463 commit fbccadb

File tree

3 files changed

+27
-25
lines changed

3 files changed

+27
-25
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ SPDX-FileCopyrightText: Contributors to PyPSA-Eur <https://github.com/pypsa/pyps
33
SPDX-License-Identifier: CC-BY-4.0
44
-->
55

6-
# Snakemake Storage Plugin: Zenodo
6+
# Snakemake Storage Plugin: Cached HTTP
77

8-
A Snakemake storage plugin for downloading files from Zenodo with local caching, checksum verification, and adaptive rate limiting.
8+
A Snakemake storage plugin for downloading files via HTTP with local caching, checksum verification, and adaptive rate limiting.
9+
10+
**Note:** This plugin is currently specifically designed for zenodo.org URLs.
911

1012
## Features
1113

@@ -22,7 +24,7 @@ A Snakemake storage plugin for downloading files from Zenodo with local caching,
2224
From the pypsa-eur repository root:
2325

2426
```bash
25-
pip install -e plugins/snakemake-storage-plugin-zenodo
27+
pip install -e plugins/snakemake-storage-plugin-cached-http
2628
```
2729

2830
## Configuration
@@ -32,10 +34,10 @@ The Zenodo storage plugin works alongside other storage providers (like HTTP). S
3234
Register additional settings in your Snakefile if you want to customize the defaults:
3335

3436
```python
35-
# Optional: Configure Zenodo storage with custom settings
37+
# Optional: Configure cached HTTP storage with custom settings
3638
# This extends the existing storage configuration (e.g., for HTTP)
37-
storage zenodo:
38-
provider="zenodo",
39+
storage cached_http:
40+
provider="cached-http",
3941
cache="~/.cache/snakemake-pypsa-eur", # Default location
4042
max_concurrent_downloads=3, # Download max 3 files at once
4143
```
@@ -48,16 +50,16 @@ If you don't explicitly configure it, the plugin will use default settings autom
4850
- Default: Platform-dependent user cache directory (via `platformdirs.user_cache_dir("snakemake-pypsa-eur")`)
4951
- Set to `""` (empty string) to disable caching
5052
- Files are cached here to avoid re-downloading
51-
- Environment variable: `SNAKEMAKE_STORAGE_ZENODO_CACHE`
53+
- Environment variable: `SNAKEMAKE_STORAGE_CACHED_HTTP_CACHE`
5254

53-
- **skip_remote_checks** (optional): Skip metadata checking with Zenodo API
55+
- **skip_remote_checks** (optional): Skip metadata checking with remote API
5456
- Default: `False` (perform checks)
5557
- Set to `True` or `"1"` to skip remote existence/size checks (useful for CI/CD)
56-
- Environment variable: `SNAKEMAKE_STORAGE_ZENODO_SKIP_REMOTE_CHECKS`
58+
- Environment variable: `SNAKEMAKE_STORAGE_CACHED_HTTP_SKIP_REMOTE_CHECKS`
5759

5860
- **max_concurrent_downloads** (optional): Maximum concurrent downloads
5961
- Default: `3`
60-
- Controls how many Zenodo files can be downloaded simultaneously
62+
- Controls how many files can be downloaded simultaneously
6163
- No environment variable support
6264

6365
## Usage
@@ -79,7 +81,7 @@ Or if you configured a tagged storage entity:
7981
```python
8082
rule download_data:
8183
input:
82-
storage.zenodo(
84+
storage.cached_http(
8385
"https://zenodo.org/records/3520874/files/natura.tiff"
8486
),
8587
output:
@@ -106,8 +108,8 @@ For continuous integration environments where you want to skip caching and remot
106108
# GitHub Actions example
107109
- name: Run snakemake workflows
108110
env:
109-
SNAKEMAKE_STORAGE_ZENODO_CACHE: ""
110-
SNAKEMAKE_STORAGE_ZENODO_SKIP_REMOTE_CHECKS: "1"
111+
SNAKEMAKE_STORAGE_CACHED_HTTP_CACHE: ""
112+
SNAKEMAKE_STORAGE_CACHED_HTTP_SKIP_REMOTE_CHECKS: "1"
111113
run: |
112114
snakemake --cores all
113115
```
@@ -134,11 +136,11 @@ The plugin automatically:
134136
### Plugin Priority
135137

136138
When using `storage()` without specifying a plugin name, Snakemake checks all installed plugins:
137-
- **Zenodo plugin**: Only accepts zenodo.org URLs (`is_valid_query` returns True only for zenodo.org)
139+
- **Cached HTTP plugin**: Only accepts zenodo.org URLs (`is_valid_query` returns True only for zenodo.org)
138140
- **HTTP plugin**: Accepts all HTTP/HTTPS URLs (including zenodo.org)
139141

140142
If both plugins are installed, zenodo.org URLs are ambiguous - both plugins accept them.
141-
Typically snakemake would raise an error: **"Multiple suitable storage providers found"** if you try to use `storage()` without specifying which plugin to use, ie. one needs to explicitly call the Zenodo provider for zenodo.org URLs using `storage.zenodo(url)` instead of `storage(url)`,
143+
Typically snakemake would raise an error: **"Multiple suitable storage providers found"** if you try to use `storage()` without specifying which plugin to use, ie. one needs to explicitly call the Cached HTTP provider for zenodo.org URLs using `storage.cached_http(url)` instead of `storage(url)`,
142144
but we monkey-patch the http plugin to refuse zenodo.org urls.
143145

144146
## License

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
# SPDX-License-Identifier: MIT
44

55
[project]
6-
name = "snakemake-storage-plugin-zenodo"
6+
name = "snakemake-storage-plugin-cached-http"
77
version = "0.1.0"
8-
description = "Snakemake storage plugin for downloading files from Zenodo with caching and rate limiting"
8+
description = "Snakemake storage plugin for downloading files via HTTP with caching and rate limiting"
99
authors = [
1010
{ name = "PyPSA-Eur Authors", email = "jonas.hoersch@openenergytransition.org" },
1111
]
1212
readme = "README.md"
1313
license = { text = "MIT" }
14-
keywords = ["snakemake", "plugin", "storage", "zenodo", "cache"]
14+
keywords = ["snakemake", "plugin", "storage", "http", "cache"]
1515
requires-python = ">=3.10"
1616
dependencies = [
1717
"httpx ~= 0.27",
@@ -43,4 +43,4 @@ requires = ["setuptools>=61.0"]
4343
build-backend = "setuptools.build_meta"
4444

4545
[project.entry-points."snakemake_storage_plugins"]
46-
zenodo = "snakemake_storage_plugin_zenodo:StorageProvider"
46+
cached-http = "snakemake_storage_plugin_cached_http:StorageProvider"

snakemake_storage_plugin_zenodo/__init__.py renamed to snakemake_storage_plugin_cached_http/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def is_zenodo_url(url):
6868
http_base.StorageProvider.is_valid_query = classmethod(
6969
lambda c, q: (
7070
StorageQueryValidationResult(
71-
query=q, valid=False, reason="Deactivated in favour of zenodo"
71+
query=q, valid=False, reason="Deactivated in favour of cached_http"
7272
)
7373
if is_zenodo_url(q)
7474
else orig_valid_query(q)
@@ -86,21 +86,21 @@ class StorageProviderSettings(SettingsBase):
8686
"snakemake-pypsa-eur", ensure_exists=False
8787
),
8888
metadata={
89-
"help": 'Cache directory for downloaded Zenodo files (default: platform-dependent user cache dir). Set to "" to deactivate caching.',
89+
"help": 'Cache directory for downloaded files (default: platform-dependent user cache dir). Set to "" to deactivate caching.',
9090
"env_var": True,
9191
},
9292
)
9393
skip_remote_checks: bool = field(
9494
default=False,
9595
metadata={
96-
"help": "Whether to skip metadata checking with zenodo (default: False, ie. do check).",
96+
"help": "Whether to skip metadata checking with remote server (default: False, ie. do check).",
9797
"env_var": True,
9898
},
9999
)
100100
max_concurrent_downloads: int | None = field(
101101
default=3,
102102
metadata={
103-
"help": "Maximum number of concurrent Zenodo downloads.",
103+
"help": "Maximum number of concurrent downloads.",
104104
"env_var": False,
105105
},
106106
)
@@ -152,7 +152,7 @@ def __post_init__(self):
152152
self._client: httpx.AsyncClient | None = None
153153
self._client_refcount: int = 0
154154

155-
# Cache for Zenodo record metadata to avoid repeated API calls
155+
# Cache for record metadata to avoid repeated API calls
156156
self._record_cache: dict[str, dict[str, ZenodoFileMetadata]] = {}
157157

158158
def use_rate_limiter(self) -> bool:
@@ -171,7 +171,7 @@ def example_queries(cls) -> list[ExampleQuery]:
171171
return [
172172
ExampleQuery(
173173
query="https://zenodo.org/records/17249457/files/ARDECO-SNPTD.2021.table.csv",
174-
description="A zenodo file URL",
174+
description="A Zenodo file URL (currently the only supported HTTP source)",
175175
type=QueryType.INPUT,
176176
)
177177
]

0 commit comments

Comments
 (0)