eumdac-store 0.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- eumdac_store/__init__.py +14 -0
- eumdac_store/_version.py +24 -0
- eumdac_store/catalog.py +137 -0
- eumdac_store/cli.py +187 -0
- eumdac_store/config.py +106 -0
- eumdac_store/fetcher.py +341 -0
- eumdac_store/integrity.py +120 -0
- eumdac_store/service.py +136 -0
- eumdac_store/storage.py +55 -0
- eumdac_store-0.4.0.dist-info/METADATA +147 -0
- eumdac_store-0.4.0.dist-info/RECORD +14 -0
- eumdac_store-0.4.0.dist-info/WHEEL +4 -0
- eumdac_store-0.4.0.dist-info/entry_points.txt +2 -0
- eumdac_store-0.4.0.dist-info/licenses/LICENSE.txt +21 -0
eumdac_store/__init__.py
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 TU Wien
|
|
3
|
+
# SPDX-FileContributor: For a full list of authors, see the AUTHORS file.
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
from .config import StoreConfig
|
|
8
|
+
from .service import DownloadResult, EumdacStore
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"EumdacStore",
|
|
12
|
+
"StoreConfig",
|
|
13
|
+
"DownloadResult",
|
|
14
|
+
]
|
eumdac_store/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.4.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 4, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|
eumdac_store/catalog.py
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 TU Wien
|
|
3
|
+
# SPDX-FileContributor: For a full list of authors, see the AUTHORS file.
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
import re
|
|
9
|
+
from datetime import datetime, timedelta, timezone
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Optional
|
|
12
|
+
|
|
13
|
+
from ducats.catalog import open_catalog, sync_product
|
|
14
|
+
from ducats.queries import ContiguityBreak, find_contiguity_gaps
|
|
15
|
+
from ducats.extract import RegexExtractor
|
|
16
|
+
from ducats.registry import ProductConfig
|
|
17
|
+
|
|
18
|
+
from .config import StoreConfig
|
|
19
|
+
from .storage import is_remote
|
|
20
|
+
|
|
21
|
+
logger = logging.getLogger("eumdac_store.catalog")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def _open(config: StoreConfig):
|
|
25
|
+
config.catalog_path.parent.mkdir(parents=True, exist_ok=True)
|
|
26
|
+
con = open_catalog(str(config.catalog_path))
|
|
27
|
+
product_dir = config.product_dir
|
|
28
|
+
if is_remote(product_dir):
|
|
29
|
+
# ducats lists files with DuckDB's glob(); a registered fsspec filesystem
|
|
30
|
+
# serves it with the same credentials the fetcher uses.
|
|
31
|
+
con.register_filesystem(product_dir.fs)
|
|
32
|
+
return con
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def raw_product(config: StoreConfig) -> ProductConfig:
|
|
36
|
+
return ProductConfig(
|
|
37
|
+
name=config.product_name,
|
|
38
|
+
base_dir=str(config.product_dir).rstrip("/") or "/",
|
|
39
|
+
glob=config.filename_glob,
|
|
40
|
+
extractor=RegexExtractor(
|
|
41
|
+
pattern=config.filename_pattern,
|
|
42
|
+
ts_format=config.filename_ts_format,
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def sync(config: StoreConfig) -> int:
|
|
48
|
+
con = _open(config)
|
|
49
|
+
try:
|
|
50
|
+
rows = sync_product(con, raw_product(config))
|
|
51
|
+
finally:
|
|
52
|
+
con.close()
|
|
53
|
+
_remove_root_catalog(config)
|
|
54
|
+
return rows
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def _remove_root_catalog(config: StoreConfig) -> None:
|
|
58
|
+
"""Drop a stale <root>/catalog.duckdb once the cache catalog has synced.
|
|
59
|
+
|
|
60
|
+
Catalogs used to sit in the download root. They are rebuilt from the listing on
|
|
61
|
+
every sync, so the old file holds nothing the new one lacks; left in place it
|
|
62
|
+
would be copied with the zips and read as current.
|
|
63
|
+
"""
|
|
64
|
+
old = config.root_catalog_path
|
|
65
|
+
if old is None or not old.exists():
|
|
66
|
+
return
|
|
67
|
+
if old.resolve() == config.catalog_path.resolve():
|
|
68
|
+
return
|
|
69
|
+
for p in (old, old.with_name(old.name + ".wal")):
|
|
70
|
+
try:
|
|
71
|
+
p.unlink(missing_ok=True)
|
|
72
|
+
except OSError as e:
|
|
73
|
+
logger.warning("Could not remove stale catalog %s: %s", p, e)
|
|
74
|
+
return
|
|
75
|
+
logger.info("Removed stale root catalog %s (now %s)", old, config.catalog_path)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def present_filenames(config: StoreConfig, *, resync: bool = True) -> set[str]:
|
|
79
|
+
con = _open(config)
|
|
80
|
+
try:
|
|
81
|
+
product = raw_product(config)
|
|
82
|
+
if resync:
|
|
83
|
+
sync_product(con, product)
|
|
84
|
+
rows = con.execute(f"SELECT file FROM {product.name}").fetchall()
|
|
85
|
+
finally:
|
|
86
|
+
con.close()
|
|
87
|
+
return {Path(r[0]).name for r in rows}
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def gap_group_cols(config: StoreConfig) -> list[str]:
|
|
91
|
+
if config.gap_group_cols is not None:
|
|
92
|
+
return list(config.gap_group_cols)
|
|
93
|
+
names = re.compile(config.filename_pattern).groupindex
|
|
94
|
+
return [n for n in names if n not in ("start", "end")]
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def gaps(
|
|
98
|
+
config: StoreConfig,
|
|
99
|
+
*,
|
|
100
|
+
start: Optional[datetime] = None,
|
|
101
|
+
end: Optional[datetime] = None,
|
|
102
|
+
resync: bool = True,
|
|
103
|
+
) -> list[ContiguityBreak]:
|
|
104
|
+
"""Breaks in the chain of stored files whose gap begins in ``[start, end)``.
|
|
105
|
+
|
|
106
|
+
Syncs the catalog from the store first (one listing), so it can run in a fresh
|
|
107
|
+
container. Times are naive UTC, as ducats stores them.
|
|
108
|
+
"""
|
|
109
|
+
con = _open(config)
|
|
110
|
+
try:
|
|
111
|
+
product = raw_product(config)
|
|
112
|
+
if resync:
|
|
113
|
+
sync_product(con, product)
|
|
114
|
+
reports = find_contiguity_gaps(
|
|
115
|
+
con,
|
|
116
|
+
product.name,
|
|
117
|
+
gap_group_cols(config),
|
|
118
|
+
min_gap=timedelta(seconds=config.gap_min_seconds),
|
|
119
|
+
max_gap=timedelta(seconds=config.gap_max_seconds),
|
|
120
|
+
)
|
|
121
|
+
finally:
|
|
122
|
+
con.close()
|
|
123
|
+
if resync:
|
|
124
|
+
_remove_root_catalog(config)
|
|
125
|
+
start, end = _naive_utc(start), _naive_utc(end)
|
|
126
|
+
return [
|
|
127
|
+
b
|
|
128
|
+
for r in reports
|
|
129
|
+
for b in r.breaks
|
|
130
|
+
if (start is None or b.end_ts >= start) and (end is None or b.end_ts < end)
|
|
131
|
+
]
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _naive_utc(t: Optional[datetime]) -> Optional[datetime]:
|
|
135
|
+
if t is None or t.tzinfo is None:
|
|
136
|
+
return t
|
|
137
|
+
return t.astimezone(timezone.utc).replace(tzinfo=None)
|
eumdac_store/cli.py
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 TU Wien
|
|
3
|
+
# SPDX-FileContributor: For a full list of authors, see the AUTHORS file.
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import argparse
|
|
8
|
+
import datetime
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Optional
|
|
13
|
+
|
|
14
|
+
from pydantic import ValidationError
|
|
15
|
+
|
|
16
|
+
from .config import StoreConfig
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _validation_error_message(e: ValidationError) -> str:
|
|
20
|
+
missing = sorted({str(err["loc"][0]) for err in e.errors() if err["type"] == "missing"})
|
|
21
|
+
if missing:
|
|
22
|
+
hint = (
|
|
23
|
+
"supply them via --config <file> (e.g. examples/ascat_szf.yaml), "
|
|
24
|
+
"$EUMDAC_STORE_CONFIG, or EUMDAC_STORE_* env vars"
|
|
25
|
+
)
|
|
26
|
+
return f"missing required product field(s): {', '.join(missing)}; {hint}"
|
|
27
|
+
return f"invalid configuration: {e}"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _load_config(args: argparse.Namespace) -> StoreConfig:
|
|
31
|
+
yaml_path = args.config or os.environ.get("EUMDAC_STORE_CONFIG")
|
|
32
|
+
overrides = {
|
|
33
|
+
"download_root_dir": args.download_root_dir or None,
|
|
34
|
+
}
|
|
35
|
+
try:
|
|
36
|
+
return StoreConfig.from_yaml(Path(yaml_path) if yaml_path else None, **overrides)
|
|
37
|
+
except ValidationError as e:
|
|
38
|
+
raise SystemExit(f"config error: {_validation_error_message(e)}")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _parse_iso(s: Optional[str]) -> Optional[datetime.datetime]:
|
|
42
|
+
return datetime.datetime.fromisoformat(s) if s else None
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def _window_kwargs(args: argparse.Namespace) -> dict:
|
|
46
|
+
if args.start or args.end:
|
|
47
|
+
kwargs = {}
|
|
48
|
+
if args.start:
|
|
49
|
+
kwargs["start"] = _parse_iso(args.start)
|
|
50
|
+
if args.end:
|
|
51
|
+
kwargs["end"] = _parse_iso(args.end)
|
|
52
|
+
return kwargs
|
|
53
|
+
return {"days": args.days}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _cmd_download(args: argparse.Namespace) -> None:
|
|
57
|
+
from .service import EumdacStore
|
|
58
|
+
|
|
59
|
+
config = _load_config(args)
|
|
60
|
+
store = EumdacStore(config)
|
|
61
|
+
result = store.download(
|
|
62
|
+
max_workers=args.workers,
|
|
63
|
+
max_retries=args.max_retries,
|
|
64
|
+
**_window_kwargs(args),
|
|
65
|
+
)
|
|
66
|
+
print(f"download: {result}")
|
|
67
|
+
for p in result.downloaded:
|
|
68
|
+
print(f" + {p.name}")
|
|
69
|
+
if result.failed:
|
|
70
|
+
for name in result.failed:
|
|
71
|
+
print(f" ! FAILED {name}")
|
|
72
|
+
raise SystemExit(3)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _cmd_list(args: argparse.Namespace) -> None:
|
|
76
|
+
from .service import EumdacStore
|
|
77
|
+
|
|
78
|
+
config = _load_config(args)
|
|
79
|
+
store = EumdacStore(config)
|
|
80
|
+
products = store.list_products(**_window_kwargs(args))
|
|
81
|
+
for product in products:
|
|
82
|
+
print(store.fetcher.product_filename(product))
|
|
83
|
+
print(f"# {len(products)} product(s)")
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _cmd_sync(args: argparse.Namespace) -> None:
|
|
87
|
+
from . import catalog
|
|
88
|
+
|
|
89
|
+
config = _load_config(args)
|
|
90
|
+
rows = catalog.sync(config)
|
|
91
|
+
print(f"synced {config.product_name}: {rows} rows from {config.product_dir} -> {config.catalog_path}")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _cmd_status(args: argparse.Namespace) -> None:
|
|
95
|
+
from ducats.catalog import open_catalog, sync_status
|
|
96
|
+
|
|
97
|
+
config = _load_config(args)
|
|
98
|
+
con = open_catalog(str(config.catalog_path))
|
|
99
|
+
try:
|
|
100
|
+
rows = sync_status(con)
|
|
101
|
+
finally:
|
|
102
|
+
con.close()
|
|
103
|
+
if not rows:
|
|
104
|
+
print("no products have been synced against this catalog")
|
|
105
|
+
else:
|
|
106
|
+
for product, synced_at, row_count in rows:
|
|
107
|
+
print(f"{product}: {row_count} rows, last synced {synced_at}")
|
|
108
|
+
|
|
109
|
+
n_quarantine = len(list(config.product_dir.glob("*.quarantine")))
|
|
110
|
+
if n_quarantine:
|
|
111
|
+
print(f"quarantine sidecars: {n_quarantine} in {config.product_dir}")
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _cmd_gaps(args: argparse.Namespace) -> None:
|
|
115
|
+
from . import catalog
|
|
116
|
+
|
|
117
|
+
config = _load_config(args)
|
|
118
|
+
start = _parse_iso(args.start)
|
|
119
|
+
end = _parse_iso(args.end)
|
|
120
|
+
if start is None and end is None and args.days is not None:
|
|
121
|
+
end = datetime.datetime.now(datetime.UTC)
|
|
122
|
+
start = end - datetime.timedelta(days=args.days)
|
|
123
|
+
breaks = catalog.gaps(config, start=start, end=end)
|
|
124
|
+
window = f"{start.isoformat() if start else '-'} .. {end.isoformat() if end else '-'}"
|
|
125
|
+
groups = ",".join(catalog.gap_group_cols(config)) or "-"
|
|
126
|
+
print(f"gaps in {config.product_dir} by {groups}, window {window}: {len(breaks)}")
|
|
127
|
+
for b in breaks:
|
|
128
|
+
group = "/".join(str(v) for v in b.group) or "-"
|
|
129
|
+
print(f" {b.kind} {group} {b.end_ts:%Y-%m-%dT%H:%M:%S} -> {b.next_start_ts:%Y-%m-%dT%H:%M:%S} ({b.delta})")
|
|
130
|
+
if breaks:
|
|
131
|
+
raise SystemExit(4)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def _add_common(p: argparse.ArgumentParser) -> None:
|
|
135
|
+
p.add_argument("--config", help="Path to a YAML config file (or $EUMDAC_STORE_CONFIG)")
|
|
136
|
+
p.add_argument("--download-root-dir", help="EUMDAC downloads root: a directory, or s3://bucket/prefix with eumdac-store[s3]")
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _add_window(p: argparse.ArgumentParser) -> None:
|
|
140
|
+
p.add_argument("--days", type=int, default=1, help="Window size in days ending now (default 1)")
|
|
141
|
+
p.add_argument("--start", help="ISO datetime window start; open-ended (everything since) if --end omitted")
|
|
142
|
+
p.add_argument("--end", help="ISO datetime window end; open-ended (everything up to) if --start omitted")
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def main(argv: Optional[list[str]] = None) -> None:
|
|
146
|
+
logging.basicConfig(
|
|
147
|
+
level=os.environ.get("EUMDAC_STORE_LOGLEVEL", "INFO"),
|
|
148
|
+
format="%(asctime)s %(levelname)s %(name)s %(message)s",
|
|
149
|
+
)
|
|
150
|
+
parser = argparse.ArgumentParser(prog="eumdac-store")
|
|
151
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
152
|
+
|
|
153
|
+
p_dl = sub.add_parser("download", help="Download a window, skipping what we already have")
|
|
154
|
+
_add_common(p_dl)
|
|
155
|
+
_add_window(p_dl)
|
|
156
|
+
p_dl.add_argument("--workers", type=int, default=None, help="Parallel downloads (clamped to 10)")
|
|
157
|
+
p_dl.add_argument("--max-retries", type=int, default=None, help="Retry budget per file")
|
|
158
|
+
p_dl.set_defaults(func=_cmd_download)
|
|
159
|
+
|
|
160
|
+
p_ls = sub.add_parser("list", help="List product names for a window (no download)")
|
|
161
|
+
_add_common(p_ls)
|
|
162
|
+
_add_window(p_ls)
|
|
163
|
+
p_ls.set_defaults(func=_cmd_list)
|
|
164
|
+
|
|
165
|
+
p_sync = sub.add_parser("sync", help="Re-sync the ducats catalog from the store")
|
|
166
|
+
_add_common(p_sync)
|
|
167
|
+
p_sync.set_defaults(func=_cmd_sync)
|
|
168
|
+
|
|
169
|
+
p_status = sub.add_parser("status", help="Catalog sync status + quarantine count")
|
|
170
|
+
_add_common(p_status)
|
|
171
|
+
p_status.set_defaults(func=_cmd_status)
|
|
172
|
+
|
|
173
|
+
p_gaps = sub.add_parser(
|
|
174
|
+
"gaps", help="Breaks in the stored files' time chain (exit 4 if any)"
|
|
175
|
+
)
|
|
176
|
+
_add_common(p_gaps)
|
|
177
|
+
p_gaps.add_argument("--days", type=float, default=None, help="Window: the last N days (default: all)")
|
|
178
|
+
p_gaps.add_argument("--start", help="ISO datetime: only gaps beginning at or after it")
|
|
179
|
+
p_gaps.add_argument("--end", help="ISO datetime: only gaps beginning before it")
|
|
180
|
+
p_gaps.set_defaults(func=_cmd_gaps)
|
|
181
|
+
|
|
182
|
+
args = parser.parse_args(argv)
|
|
183
|
+
args.func(args)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
if __name__ == "__main__":
|
|
187
|
+
main()
|
eumdac_store/config.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 TU Wien
|
|
3
|
+
# SPDX-FileContributor: For a full list of authors, see the AUTHORS file.
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import Any, Optional, Union
|
|
10
|
+
|
|
11
|
+
import yaml
|
|
12
|
+
from pydantic import field_validator, model_validator
|
|
13
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
14
|
+
|
|
15
|
+
from .storage import StorePath, is_url, open_root
|
|
16
|
+
|
|
17
|
+
EUMDAC_PARALLEL_CONNECTION_CEILING = 10
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class StoreConfig(BaseSettings):
|
|
21
|
+
|
|
22
|
+
model_config = SettingsConfigDict(env_prefix="EUMDAC_STORE_", extra="ignore")
|
|
23
|
+
|
|
24
|
+
collection_id: str
|
|
25
|
+
# A local directory, or a URL such as s3://bucket/prefix (needs eumdac-store[s3]).
|
|
26
|
+
download_root_dir: Union[Path, str]
|
|
27
|
+
# fsspec options for a URL root, e.g. {profile: ..., endpoint_url: ...}; s3fs
|
|
28
|
+
# also reads AWS_PROFILE / AWS_ENDPOINT_URL / AWS_* keys from the environment.
|
|
29
|
+
storage_options: dict[str, Any] = {}
|
|
30
|
+
# The DuckDB catalog is a local cache of the root's listing, rebuilt on every sync.
|
|
31
|
+
# Default: $XDG_CACHE_HOME/eumdac-store/<root without scheme or leading />/catalog.duckdb.
|
|
32
|
+
catalog_file: Optional[Path] = None
|
|
33
|
+
product_name: str
|
|
34
|
+
filename_glob: str
|
|
35
|
+
filename_pattern: str
|
|
36
|
+
filename_ts_format: str = "%Y%m%d%H%M%S"
|
|
37
|
+
|
|
38
|
+
max_workers: int = EUMDAC_PARALLEL_CONNECTION_CEILING
|
|
39
|
+
max_retries: int = 3
|
|
40
|
+
quarantine_cooloff_hours: float = 2.0
|
|
41
|
+
|
|
42
|
+
# `gaps`: consecutive files of a group chain when the next starts between
|
|
43
|
+
# gap_min_seconds and gap_max_seconds after the last one's end (SZF: 0-1 s).
|
|
44
|
+
# Groups default to the pattern's named groups other than start/end.
|
|
45
|
+
gap_group_cols: Optional[list[str]] = None
|
|
46
|
+
gap_min_seconds: float = 0.0
|
|
47
|
+
gap_max_seconds: float = 1.0
|
|
48
|
+
|
|
49
|
+
@field_validator("download_root_dir", mode="before")
|
|
50
|
+
@classmethod
|
|
51
|
+
def _root_path_or_url(cls, v: Any) -> Any:
|
|
52
|
+
if isinstance(v, str) and not is_url(v):
|
|
53
|
+
return Path(v)
|
|
54
|
+
if isinstance(v, str):
|
|
55
|
+
return v.rstrip("/")
|
|
56
|
+
return v
|
|
57
|
+
|
|
58
|
+
@property
|
|
59
|
+
def is_remote(self) -> bool:
|
|
60
|
+
return is_url(self.download_root_dir)
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def root(self) -> StorePath:
|
|
64
|
+
return open_root(self.download_root_dir, self.storage_options)
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def product_dir(self) -> StorePath:
|
|
68
|
+
return self.root / self.product_name
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def catalog_path(self) -> Path:
|
|
72
|
+
if self.catalog_file is not None:
|
|
73
|
+
return Path(self.catalog_file)
|
|
74
|
+
cache = Path(os.environ.get("XDG_CACHE_HOME") or Path.home() / ".cache")
|
|
75
|
+
if self.is_remote:
|
|
76
|
+
_, _, key = str(self.download_root_dir).partition("://")
|
|
77
|
+
else:
|
|
78
|
+
key = str(Path(self.download_root_dir).resolve()).lstrip("/")
|
|
79
|
+
return cache / "eumdac-store" / key / "catalog.duckdb"
|
|
80
|
+
|
|
81
|
+
@property
|
|
82
|
+
def root_catalog_path(self) -> Optional[Path]:
|
|
83
|
+
"""Where catalogs lived before they moved to the cache: <root>/catalog.duckdb."""
|
|
84
|
+
if self.is_remote:
|
|
85
|
+
return None
|
|
86
|
+
return Path(self.download_root_dir) / "catalog.duckdb"
|
|
87
|
+
|
|
88
|
+
@model_validator(mode="after")
|
|
89
|
+
def _validate_product_name(self) -> "StoreConfig":
|
|
90
|
+
if not self.product_name.isidentifier():
|
|
91
|
+
raise ValueError(
|
|
92
|
+
f"product_name {self.product_name!r} must be a valid identifier "
|
|
93
|
+
"— ducats uses it raw as a SQL table name"
|
|
94
|
+
)
|
|
95
|
+
return self
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def from_yaml(cls, yaml_path: Optional[Path] = None, **overrides) -> "StoreConfig":
|
|
99
|
+
config_dict: dict = {}
|
|
100
|
+
if yaml_path and Path(yaml_path).exists():
|
|
101
|
+
with open(yaml_path, "r") as f:
|
|
102
|
+
loaded = yaml.safe_load(f)
|
|
103
|
+
if loaded:
|
|
104
|
+
config_dict.update(loaded)
|
|
105
|
+
config_dict.update({k: v for k, v in overrides.items() if v is not None})
|
|
106
|
+
return cls(**config_dict)
|
eumdac_store/fetcher.py
ADDED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 TU Wien
|
|
3
|
+
# SPDX-FileContributor: For a full list of authors, see the AUTHORS file.
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import datetime
|
|
8
|
+
import json
|
|
9
|
+
import logging
|
|
10
|
+
import os
|
|
11
|
+
import shutil
|
|
12
|
+
import tempfile
|
|
13
|
+
import time
|
|
14
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import List, Optional
|
|
17
|
+
|
|
18
|
+
import eumdac
|
|
19
|
+
import requests
|
|
20
|
+
import urllib3.exceptions
|
|
21
|
+
from dotenv import load_dotenv
|
|
22
|
+
from eumdac.product import ProductError
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
#: our own EUMDAC_* variables, which are not eumdac's settings
|
|
26
|
+
_OWN_ENV = ("EUMDAC_KEY", "EUMDAC_SECRET")
|
|
27
|
+
_OWN_ENV_PREFIXES = ("EUMDAC_STORE_", "EUMDAC_FETCH_")
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def _eumdac_config_without_ours() -> None:
|
|
31
|
+
"""Build eumdac's shared config from the environment minus our own variables.
|
|
32
|
+
|
|
33
|
+
eumdac 4 reads every ``EUMDAC_*`` variable as a setting and warns "no matching config
|
|
34
|
+
key" for each one it doesn't know, which is all of ours (credentials, ``EUMDAC_STORE_*``
|
|
35
|
+
config, the fetch DAG's ``EUMDAC_FETCH_*``). Its own variables still apply.
|
|
36
|
+
"""
|
|
37
|
+
try:
|
|
38
|
+
from eumdac import config as eumdac_config
|
|
39
|
+
except ImportError: # pragma: no cover - an eumdac without the shared config
|
|
40
|
+
return
|
|
41
|
+
if not hasattr(eumdac_config, "_config_instance"): # pragma: no cover
|
|
42
|
+
return
|
|
43
|
+
env = {
|
|
44
|
+
name: value
|
|
45
|
+
for name, value in os.environ.items()
|
|
46
|
+
if name not in _OWN_ENV and not name.startswith(_OWN_ENV_PREFIXES)
|
|
47
|
+
}
|
|
48
|
+
eumdac_config._config_instance = eumdac_config.Config(env=env)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _xdg_config_dir() -> Path:
|
|
52
|
+
return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config")
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _load_credentials() -> tuple[str, str]:
|
|
56
|
+
consumer_key = os.environ.get("EUMDAC_KEY")
|
|
57
|
+
consumer_secret = os.environ.get("EUMDAC_SECRET")
|
|
58
|
+
if consumer_key and consumer_secret:
|
|
59
|
+
return consumer_key, consumer_secret
|
|
60
|
+
cred_file = _xdg_config_dir() / "eumdac-store" / "credentials.json"
|
|
61
|
+
if cred_file.is_file():
|
|
62
|
+
data = json.loads(cred_file.read_text())
|
|
63
|
+
return data["consumer_key"], data["consumer_secret"]
|
|
64
|
+
raise ValueError(
|
|
65
|
+
"set EUMDAC_KEY/EUMDAC_SECRET (env or .env) or put EUMETSAT-style "
|
|
66
|
+
f"credentials.json at {cred_file}"
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
from .config import EUMDAC_PARALLEL_CONNECTION_CEILING, StoreConfig
|
|
70
|
+
from .storage import is_remote, publish
|
|
71
|
+
from .integrity import (
|
|
72
|
+
CorruptDownloadError,
|
|
73
|
+
CorruptKind,
|
|
74
|
+
clear_quarantine,
|
|
75
|
+
write_quarantine,
|
|
76
|
+
zip_is_valid,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class EumdacFetcher:
|
|
81
|
+
def __init__(self, config: StoreConfig, *, authenticate: bool = True):
|
|
82
|
+
self.config = config
|
|
83
|
+
self.logger = logging.getLogger("eumdac_store.fetcher")
|
|
84
|
+
|
|
85
|
+
load_dotenv(".env")
|
|
86
|
+
self.token = None
|
|
87
|
+
self.datastore = None
|
|
88
|
+
self.collection = None
|
|
89
|
+
|
|
90
|
+
if authenticate:
|
|
91
|
+
self.credentials = _load_credentials()
|
|
92
|
+
self._authenticate()
|
|
93
|
+
|
|
94
|
+
def _authenticate(self) -> None:
|
|
95
|
+
_eumdac_config_without_ours()
|
|
96
|
+
try:
|
|
97
|
+
self.token = eumdac.AccessToken(self.credentials)
|
|
98
|
+
self.datastore = eumdac.DataStore(self.token)
|
|
99
|
+
self.collection = self.datastore.get_collection(self.config.collection_id)
|
|
100
|
+
self.logger.info(
|
|
101
|
+
"Authenticated with EUMETSAT, collection: %s", self.config.collection_id
|
|
102
|
+
)
|
|
103
|
+
except Exception as e:
|
|
104
|
+
self.logger.error("Authentication failed: %s", e)
|
|
105
|
+
raise
|
|
106
|
+
|
|
107
|
+
def _resolve_window(
|
|
108
|
+
self,
|
|
109
|
+
*,
|
|
110
|
+
days: Optional[int] = None,
|
|
111
|
+
specific_dates: Optional[List[datetime.datetime]] = None,
|
|
112
|
+
start: Optional[datetime.datetime] = None,
|
|
113
|
+
end: Optional[datetime.datetime] = None,
|
|
114
|
+
) -> tuple[Optional[datetime.datetime], Optional[datetime.datetime]]:
|
|
115
|
+
if start is not None or end is not None:
|
|
116
|
+
if end is None:
|
|
117
|
+
end = datetime.datetime.now(datetime.UTC)
|
|
118
|
+
return start, end
|
|
119
|
+
if specific_dates:
|
|
120
|
+
min_date = min(d.date() for d in specific_dates)
|
|
121
|
+
max_date = max(d.date() for d in specific_dates)
|
|
122
|
+
dt_start = datetime.datetime.combine(min_date, datetime.time.min)
|
|
123
|
+
dt_end = datetime.datetime.combine(max_date, datetime.time.max) + datetime.timedelta(
|
|
124
|
+
microseconds=999999
|
|
125
|
+
)
|
|
126
|
+
return dt_start, dt_end
|
|
127
|
+
if days is not None:
|
|
128
|
+
dt_end = datetime.datetime.now(datetime.UTC)
|
|
129
|
+
dt_start = dt_end - datetime.timedelta(days=days)
|
|
130
|
+
return dt_start, dt_end
|
|
131
|
+
raise ValueError("one of `days`, `specific_dates`, `start`, or `end` must be provided")
|
|
132
|
+
|
|
133
|
+
def search(
|
|
134
|
+
self,
|
|
135
|
+
*,
|
|
136
|
+
days: Optional[int] = None,
|
|
137
|
+
specific_dates: Optional[List[datetime.datetime]] = None,
|
|
138
|
+
start: Optional[datetime.datetime] = None,
|
|
139
|
+
end: Optional[datetime.datetime] = None,
|
|
140
|
+
) -> list:
|
|
141
|
+
dt_start, dt_end = self._resolve_window(
|
|
142
|
+
days=days, specific_dates=specific_dates, start=start, end=end
|
|
143
|
+
)
|
|
144
|
+
try:
|
|
145
|
+
query: dict = {}
|
|
146
|
+
if dt_start is not None:
|
|
147
|
+
query["dtstart"] = dt_start
|
|
148
|
+
if dt_end is not None:
|
|
149
|
+
query["dtend"] = dt_end
|
|
150
|
+
products = list(self.collection.search(**query))
|
|
151
|
+
except Exception as e:
|
|
152
|
+
self.logger.error("search failed: %s", e)
|
|
153
|
+
raise
|
|
154
|
+
|
|
155
|
+
if specific_dates:
|
|
156
|
+
wanted_dates = {d.date() for d in specific_dates}
|
|
157
|
+
products = [
|
|
158
|
+
p
|
|
159
|
+
for p in products
|
|
160
|
+
if p.sensing_start.date() in wanted_dates
|
|
161
|
+
or getattr(p, "sensing_end", p.sensing_start).date() in wanted_dates
|
|
162
|
+
]
|
|
163
|
+
self.logger.info("search: %d product(s) in window", len(products))
|
|
164
|
+
return products
|
|
165
|
+
|
|
166
|
+
@staticmethod
|
|
167
|
+
def product_filename(product) -> str:
|
|
168
|
+
name = str(product)
|
|
169
|
+
return name if name.endswith(".zip") else name + ".zip"
|
|
170
|
+
|
|
171
|
+
@staticmethod
|
|
172
|
+
def product_size_kb(product) -> int | None:
|
|
173
|
+
size = getattr(product, "size", None)
|
|
174
|
+
return int(size) if size is not None else None
|
|
175
|
+
|
|
176
|
+
def download_products(
|
|
177
|
+
self,
|
|
178
|
+
products: List,
|
|
179
|
+
*,
|
|
180
|
+
max_workers: Optional[int] = None,
|
|
181
|
+
max_retries: Optional[int] = None,
|
|
182
|
+
) -> List:
|
|
183
|
+
retries = self.config.max_retries if max_retries is None else max_retries
|
|
184
|
+
if max_workers is None:
|
|
185
|
+
effective_workers = EUMDAC_PARALLEL_CONNECTION_CEILING
|
|
186
|
+
elif max_workers > EUMDAC_PARALLEL_CONNECTION_CEILING:
|
|
187
|
+
self.logger.warning(
|
|
188
|
+
"Requested max_workers=%d exceeds EUMDAC's %d-connection ceiling; clamping.",
|
|
189
|
+
max_workers,
|
|
190
|
+
EUMDAC_PARALLEL_CONNECTION_CEILING,
|
|
191
|
+
)
|
|
192
|
+
effective_workers = EUMDAC_PARALLEL_CONNECTION_CEILING
|
|
193
|
+
else:
|
|
194
|
+
effective_workers = max_workers
|
|
195
|
+
|
|
196
|
+
self.logger.info(
|
|
197
|
+
"Fetching %d product(s) with %d parallel worker(s)", len(products), effective_workers
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
downloaded: List = []
|
|
201
|
+
with ThreadPoolExecutor(max_workers=effective_workers) as executor:
|
|
202
|
+
future_to_product = {
|
|
203
|
+
executor.submit(
|
|
204
|
+
self._fetch_single_product_with_retry, product, str(product), retries
|
|
205
|
+
): str(product)
|
|
206
|
+
for product in products
|
|
207
|
+
}
|
|
208
|
+
for future in as_completed(future_to_product):
|
|
209
|
+
product_id = future_to_product[future]
|
|
210
|
+
try:
|
|
211
|
+
result = future.result()
|
|
212
|
+
if result:
|
|
213
|
+
downloaded.append(result)
|
|
214
|
+
self.logger.info(
|
|
215
|
+
"Download complete (%d/%d): %s",
|
|
216
|
+
len(downloaded),
|
|
217
|
+
len(products),
|
|
218
|
+
product_id,
|
|
219
|
+
)
|
|
220
|
+
except Exception as e:
|
|
221
|
+
self.logger.error("Failed to download %s: %s", product_id, e)
|
|
222
|
+
return downloaded
|
|
223
|
+
|
|
224
|
+
def _fetch_single_product_with_retry(
|
|
225
|
+
self,
|
|
226
|
+
product,
|
|
227
|
+
product_id: str,
|
|
228
|
+
max_retries: int,
|
|
229
|
+
):
|
|
230
|
+
last_corrupt_kind: Optional[CorruptKind] = None
|
|
231
|
+
last_corrupt_reason: Optional[str] = None
|
|
232
|
+
for attempt in range(max_retries):
|
|
233
|
+
try:
|
|
234
|
+
return self._fetch_single_product(product, product_id)
|
|
235
|
+
except (
|
|
236
|
+
requests.exceptions.RequestException,
|
|
237
|
+
urllib3.exceptions.HTTPError,
|
|
238
|
+
OSError,
|
|
239
|
+
) as e:
|
|
240
|
+
last_corrupt_kind = None
|
|
241
|
+
last_corrupt_reason = None
|
|
242
|
+
if attempt < max_retries - 1:
|
|
243
|
+
wait_time = 2**attempt
|
|
244
|
+
self.logger.warning(
|
|
245
|
+
"Network error for %s (%s: %s), attempt %d/%d. Retrying in %ds...",
|
|
246
|
+
product_id,
|
|
247
|
+
type(e).__name__,
|
|
248
|
+
e,
|
|
249
|
+
attempt + 1,
|
|
250
|
+
max_retries,
|
|
251
|
+
wait_time,
|
|
252
|
+
)
|
|
253
|
+
time.sleep(wait_time)
|
|
254
|
+
else:
|
|
255
|
+
self.logger.error(
|
|
256
|
+
"Failed to download %s after %d attempts: %s",
|
|
257
|
+
product_id,
|
|
258
|
+
max_retries,
|
|
259
|
+
e,
|
|
260
|
+
)
|
|
261
|
+
return None
|
|
262
|
+
except CorruptDownloadError as e:
|
|
263
|
+
last_corrupt_kind = e.kind
|
|
264
|
+
last_corrupt_reason = e.reason
|
|
265
|
+
if attempt < max_retries - 1:
|
|
266
|
+
wait_time = 2**attempt
|
|
267
|
+
self.logger.warning(
|
|
268
|
+
"Corrupt download for %s (%s: %s), attempt %d/%d. Retrying in %ds...",
|
|
269
|
+
product_id,
|
|
270
|
+
e.kind.value,
|
|
271
|
+
e.reason,
|
|
272
|
+
attempt + 1,
|
|
273
|
+
max_retries,
|
|
274
|
+
wait_time,
|
|
275
|
+
)
|
|
276
|
+
time.sleep(wait_time)
|
|
277
|
+
else:
|
|
278
|
+
self.logger.error(
|
|
279
|
+
"Persistent corruption for %s after %d attempts (%s: %s). Quarantining.",
|
|
280
|
+
product_id,
|
|
281
|
+
max_retries,
|
|
282
|
+
e.kind.value,
|
|
283
|
+
e.reason,
|
|
284
|
+
)
|
|
285
|
+
except ProductError as e:
|
|
286
|
+
self.logger.error("Product error for %s: %s", product_id, e.msg)
|
|
287
|
+
return None
|
|
288
|
+
|
|
289
|
+
if last_corrupt_reason is not None:
|
|
290
|
+
local_name = product_id if product_id.endswith(".zip") else product_id + ".zip"
|
|
291
|
+
local_path = self.config.product_dir / local_name
|
|
292
|
+
write_quarantine(
|
|
293
|
+
local_path,
|
|
294
|
+
last_corrupt_reason,
|
|
295
|
+
attempts=max_retries,
|
|
296
|
+
cooloff_hours=self.config.quarantine_cooloff_hours,
|
|
297
|
+
kind=last_corrupt_kind,
|
|
298
|
+
)
|
|
299
|
+
return None
|
|
300
|
+
|
|
301
|
+
def _fetch_single_product(self, product, product_id: str):
|
|
302
|
+
if not product_id.endswith(".zip"):
|
|
303
|
+
product_id = product_id + ".zip"
|
|
304
|
+
local_path = self.config.product_dir / product_id
|
|
305
|
+
if is_remote(local_path):
|
|
306
|
+
# Download and validate on local disk, then publish with one upload.
|
|
307
|
+
staging = Path(tempfile.mkdtemp(prefix="eumdac-store-"))
|
|
308
|
+
partial_path = staging / (product_id + ".partial")
|
|
309
|
+
else:
|
|
310
|
+
staging = None
|
|
311
|
+
partial_path = local_path.with_suffix(local_path.suffix + ".partial")
|
|
312
|
+
local_path.parent.mkdir(parents=True, exist_ok=True)
|
|
313
|
+
|
|
314
|
+
published = False
|
|
315
|
+
try:
|
|
316
|
+
try:
|
|
317
|
+
with product.open() as fsrc:
|
|
318
|
+
with open(partial_path, mode="wb") as fdst:
|
|
319
|
+
shutil.copyfileobj(fsrc, fdst, length=1024 * 1024)
|
|
320
|
+
except ProductError as e:
|
|
321
|
+
self.logger.error("Error opening product: %s", e.msg)
|
|
322
|
+
raise
|
|
323
|
+
|
|
324
|
+
ok, kind, reason = zip_is_valid(
|
|
325
|
+
partial_path, expected_size_kb=self.product_size_kb(product)
|
|
326
|
+
)
|
|
327
|
+
if not ok:
|
|
328
|
+
assert kind is not None
|
|
329
|
+
assert reason is not None
|
|
330
|
+
raise CorruptDownloadError(kind, reason)
|
|
331
|
+
|
|
332
|
+
publish(partial_path, local_path)
|
|
333
|
+
published = True
|
|
334
|
+
clear_quarantine(local_path)
|
|
335
|
+
self.logger.info("Downloaded: %s -> %s", product_id, local_path)
|
|
336
|
+
return local_path
|
|
337
|
+
finally:
|
|
338
|
+
if not published:
|
|
339
|
+
partial_path.unlink(missing_ok=True)
|
|
340
|
+
if staging is not None:
|
|
341
|
+
shutil.rmtree(staging, ignore_errors=True)
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 TU Wien
|
|
3
|
+
# SPDX-FileContributor: For a full list of authors, see the AUTHORS file.
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import datetime
|
|
8
|
+
import json
|
|
9
|
+
import logging
|
|
10
|
+
import time
|
|
11
|
+
import zipfile
|
|
12
|
+
from enum import Enum
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Optional
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger("eumdac_store.integrity")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class CorruptKind(str, Enum):
|
|
20
|
+
MISSING = "missing"
|
|
21
|
+
SIZE = "size"
|
|
22
|
+
ZIP = "zip"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class CorruptDownloadError(Exception):
|
|
26
|
+
def __init__(self, kind: CorruptKind, reason: str):
|
|
27
|
+
super().__init__(reason)
|
|
28
|
+
self.kind = kind
|
|
29
|
+
self.reason = reason
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def zip_is_valid(
|
|
33
|
+
path: Path,
|
|
34
|
+
expected_size_kb: Optional[int] = None,
|
|
35
|
+
) -> tuple[bool, Optional[CorruptKind], Optional[str]]:
|
|
36
|
+
if not path.exists():
|
|
37
|
+
return False, CorruptKind.MISSING, "missing"
|
|
38
|
+
actual_size = path.stat().st_size
|
|
39
|
+
if expected_size_kb is not None:
|
|
40
|
+
actual_kb_floor = actual_size // 1024
|
|
41
|
+
if actual_kb_floor != expected_size_kb:
|
|
42
|
+
return (
|
|
43
|
+
False,
|
|
44
|
+
CorruptKind.SIZE,
|
|
45
|
+
f"size {actual_size} bytes (floor {actual_kb_floor} KB) "
|
|
46
|
+
f"!= expected {expected_size_kb} KB",
|
|
47
|
+
)
|
|
48
|
+
with path.open("rb") as fh:
|
|
49
|
+
is_zip = zipfile.is_zipfile(fh)
|
|
50
|
+
if not is_zip:
|
|
51
|
+
return (
|
|
52
|
+
False,
|
|
53
|
+
CorruptKind.ZIP,
|
|
54
|
+
"not a valid zip file (magic bytes / central directory check failed)",
|
|
55
|
+
)
|
|
56
|
+
return True, None, None
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def quarantine_path(path: Path) -> Path:
|
|
60
|
+
return path.with_suffix(path.suffix + ".quarantine")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def is_actively_quarantined(path: Path, cooloff_hours: float) -> bool:
|
|
64
|
+
qp = quarantine_path(path)
|
|
65
|
+
if not qp.exists():
|
|
66
|
+
return False
|
|
67
|
+
mtime = qp.stat().st_mtime or _recorded_quarantine_time(qp)
|
|
68
|
+
age_hours = (time.time() - mtime) / 3600
|
|
69
|
+
return age_hours < cooloff_hours
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def _recorded_quarantine_time(qp) -> float:
|
|
73
|
+
"""The sidecar's own ``quarantined_at``, for stores that report no mtime."""
|
|
74
|
+
try:
|
|
75
|
+
stamp = json.loads(qp.read_text())["quarantined_at"]
|
|
76
|
+
# Written as isoformat() + "Z" on an aware datetime ("...+00:00Z").
|
|
77
|
+
stamp = stamp.removesuffix("Z")
|
|
78
|
+
dt = datetime.datetime.fromisoformat(stamp)
|
|
79
|
+
if dt.tzinfo is None:
|
|
80
|
+
dt = dt.replace(tzinfo=datetime.UTC)
|
|
81
|
+
return dt.timestamp()
|
|
82
|
+
except (OSError, ValueError, KeyError, TypeError):
|
|
83
|
+
return 0.0
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def write_quarantine(
|
|
87
|
+
path: Path,
|
|
88
|
+
reason: str,
|
|
89
|
+
attempts: int,
|
|
90
|
+
cooloff_hours: float,
|
|
91
|
+
*,
|
|
92
|
+
kind: Optional[CorruptKind] = None,
|
|
93
|
+
) -> None:
|
|
94
|
+
qp = quarantine_path(path)
|
|
95
|
+
payload = {
|
|
96
|
+
"filename": path.name,
|
|
97
|
+
"kind": kind.value if kind else None,
|
|
98
|
+
"reason": reason,
|
|
99
|
+
"attempts": attempts,
|
|
100
|
+
"quarantined_at": datetime.datetime.now(datetime.UTC).isoformat() + "Z",
|
|
101
|
+
"cooloff_hours": cooloff_hours,
|
|
102
|
+
"note": (
|
|
103
|
+
"EUMDAC source repeatedly returned a corrupt file. "
|
|
104
|
+
"Sidecar will be ignored after cooloff; remove manually to retry sooner."
|
|
105
|
+
),
|
|
106
|
+
}
|
|
107
|
+
try:
|
|
108
|
+
qp.write_text(json.dumps(payload, indent=2))
|
|
109
|
+
except OSError as e:
|
|
110
|
+
logger.error("Could not write quarantine sidecar %s: %s", qp.name, e)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def clear_quarantine(path: Path) -> None:
|
|
114
|
+
qp = quarantine_path(path)
|
|
115
|
+
if qp.exists():
|
|
116
|
+
try:
|
|
117
|
+
qp.unlink()
|
|
118
|
+
logger.info("Cleared stale quarantine sidecar: %s", qp.name)
|
|
119
|
+
except OSError as e:
|
|
120
|
+
logger.warning("Could not clear quarantine sidecar %s: %s", qp.name, e)
|
eumdac_store/service.py
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 TU Wien
|
|
3
|
+
# SPDX-FileContributor: For a full list of authors, see the AUTHORS file.
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import datetime
|
|
8
|
+
import logging
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import List, Optional
|
|
12
|
+
|
|
13
|
+
from . import catalog
|
|
14
|
+
from .config import StoreConfig
|
|
15
|
+
from .fetcher import EumdacFetcher
|
|
16
|
+
from .integrity import CorruptKind, is_actively_quarantined, zip_is_valid
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class DownloadResult:
|
|
21
|
+
downloaded: List[Path] = field(default_factory=list)
|
|
22
|
+
skipped_present: List[str] = field(default_factory=list)
|
|
23
|
+
skipped_quarantined: List[str] = field(default_factory=list)
|
|
24
|
+
failed: List[str] = field(default_factory=list)
|
|
25
|
+
catalog_rows: int = 0
|
|
26
|
+
|
|
27
|
+
def __str__(self) -> str:
|
|
28
|
+
return (
|
|
29
|
+
f"downloaded={len(self.downloaded)} "
|
|
30
|
+
f"skipped_present={len(self.skipped_present)} "
|
|
31
|
+
f"skipped_quarantined={len(self.skipped_quarantined)} "
|
|
32
|
+
f"failed={len(self.failed)} "
|
|
33
|
+
f"catalog_rows={self.catalog_rows}"
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class EumdacStore:
|
|
38
|
+
def __init__(self, config: StoreConfig, *, fetcher: Optional[EumdacFetcher] = None):
|
|
39
|
+
self.config = config
|
|
40
|
+
self.logger = logging.getLogger("eumdac_store.service")
|
|
41
|
+
self.fetcher = fetcher if fetcher is not None else EumdacFetcher(config)
|
|
42
|
+
|
|
43
|
+
def list_products(
|
|
44
|
+
self,
|
|
45
|
+
*,
|
|
46
|
+
days: Optional[int] = None,
|
|
47
|
+
specific_dates: Optional[List[datetime.datetime]] = None,
|
|
48
|
+
start: Optional[datetime.datetime] = None,
|
|
49
|
+
end: Optional[datetime.datetime] = None,
|
|
50
|
+
) -> list:
|
|
51
|
+
return self.fetcher.search(
|
|
52
|
+
days=days, specific_dates=specific_dates, start=start, end=end
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def download(
|
|
56
|
+
self,
|
|
57
|
+
*,
|
|
58
|
+
days: Optional[int] = None,
|
|
59
|
+
specific_dates: Optional[List[datetime.datetime]] = None,
|
|
60
|
+
start: Optional[datetime.datetime] = None,
|
|
61
|
+
end: Optional[datetime.datetime] = None,
|
|
62
|
+
max_workers: Optional[int] = None,
|
|
63
|
+
max_retries: Optional[int] = None,
|
|
64
|
+
) -> DownloadResult:
|
|
65
|
+
result = DownloadResult()
|
|
66
|
+
|
|
67
|
+
products = self.fetcher.search(
|
|
68
|
+
days=days, specific_dates=specific_dates, start=start, end=end
|
|
69
|
+
)
|
|
70
|
+
if not products:
|
|
71
|
+
self.logger.info("download: empty listing for window")
|
|
72
|
+
result.catalog_rows = catalog.sync(self.config)
|
|
73
|
+
return result
|
|
74
|
+
|
|
75
|
+
present = catalog.present_filenames(self.config)
|
|
76
|
+
|
|
77
|
+
to_fetch = []
|
|
78
|
+
for product in products:
|
|
79
|
+
name = self.fetcher.product_filename(product)
|
|
80
|
+
local_path = self.config.product_dir / name
|
|
81
|
+
|
|
82
|
+
if is_actively_quarantined(local_path, self.config.quarantine_cooloff_hours):
|
|
83
|
+
result.skipped_quarantined.append(name)
|
|
84
|
+
self.logger.warning(
|
|
85
|
+
"Skipping %s: actively quarantined (< %.1fh since last failure). "
|
|
86
|
+
"Remove %s.quarantine to force retry.",
|
|
87
|
+
name,
|
|
88
|
+
self.config.quarantine_cooloff_hours,
|
|
89
|
+
name,
|
|
90
|
+
)
|
|
91
|
+
continue
|
|
92
|
+
|
|
93
|
+
if name in present:
|
|
94
|
+
ok, kind, reason = zip_is_valid(
|
|
95
|
+
local_path, expected_size_kb=self.fetcher.product_size_kb(product)
|
|
96
|
+
)
|
|
97
|
+
if ok:
|
|
98
|
+
result.skipped_present.append(name)
|
|
99
|
+
continue
|
|
100
|
+
self._quarantine_corrupt_existing(local_path, kind, reason)
|
|
101
|
+
|
|
102
|
+
to_fetch.append(product)
|
|
103
|
+
|
|
104
|
+
if result.skipped_present:
|
|
105
|
+
self.logger.info("Skipping %d file(s) already present", len(result.skipped_present))
|
|
106
|
+
|
|
107
|
+
if to_fetch:
|
|
108
|
+
expected = {self.fetcher.product_filename(p) for p in to_fetch}
|
|
109
|
+
downloaded = self.fetcher.download_products(
|
|
110
|
+
to_fetch, max_workers=max_workers, max_retries=max_retries
|
|
111
|
+
)
|
|
112
|
+
result.downloaded = downloaded
|
|
113
|
+
got = {p.name for p in downloaded}
|
|
114
|
+
result.failed = sorted(expected - got)
|
|
115
|
+
else:
|
|
116
|
+
self.logger.info("Nothing to download; catalog already covers the window")
|
|
117
|
+
|
|
118
|
+
result.catalog_rows = catalog.sync(self.config)
|
|
119
|
+
return result
|
|
120
|
+
|
|
121
|
+
def _quarantine_corrupt_existing(
|
|
122
|
+
self, path: Path, kind: Optional[CorruptKind], reason: Optional[str]
|
|
123
|
+
) -> None:
|
|
124
|
+
ts = datetime.datetime.now(datetime.UTC).strftime("%Y%m%dT%H%M%SZ")
|
|
125
|
+
corrupt_path = path.with_suffix(path.suffix + f".corrupt.{ts}")
|
|
126
|
+
self.logger.warning(
|
|
127
|
+
"Existing file %s failed validation (%s: %s); renaming to %s and re-fetching.",
|
|
128
|
+
path.name,
|
|
129
|
+
kind.value if kind else "?",
|
|
130
|
+
reason,
|
|
131
|
+
corrupt_path.name,
|
|
132
|
+
)
|
|
133
|
+
try:
|
|
134
|
+
path.rename(corrupt_path)
|
|
135
|
+
except OSError as e:
|
|
136
|
+
self.logger.error("Could not rename corrupt file %s: %s", path.name, e)
|
eumdac_store/storage.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# SPDX-FileCopyrightText: Copyright (c) 2026 TU Wien
|
|
3
|
+
# SPDX-FileContributor: For a full list of authors, see the AUTHORS file.
|
|
4
|
+
|
|
5
|
+
"""Where the store lives: a local directory or an fsspec URL (``s3://bucket/prefix``).
|
|
6
|
+
|
|
7
|
+
A local root is a plain :class:`pathlib.Path` and behaves exactly as before. A URL
|
|
8
|
+
root is a :class:`upath.UPath`, which offers the same path API (``/``, ``exists``,
|
|
9
|
+
``stat``, ``open``, ``rename``, ``glob``, ``unlink``) over the object store, so the
|
|
10
|
+
fetcher, quarantine sidecars and catalog use one code path for both. The S3 extra
|
|
11
|
+
(``eumdac-store[s3]``) provides ``universal-pathlib`` and ``s3fs``.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
from typing import Any, Union
|
|
18
|
+
|
|
19
|
+
StorePath = Union[Path, Any] # Path, or upath.UPath for a URL root
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def is_url(root: Union[str, Path]) -> bool:
|
|
23
|
+
return "://" in str(root)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def open_root(root: Union[str, Path], storage_options: dict | None = None) -> StorePath:
|
|
27
|
+
if not is_url(root):
|
|
28
|
+
return Path(root)
|
|
29
|
+
try:
|
|
30
|
+
from upath import UPath
|
|
31
|
+
except ImportError as e: # pragma: no cover - depends on the install
|
|
32
|
+
raise ImportError(
|
|
33
|
+
f"download_root_dir {root!s} is a URL; install eumdac-store[s3] "
|
|
34
|
+
"(universal-pathlib + s3fs) to use an object-store root"
|
|
35
|
+
) from e
|
|
36
|
+
options = {"use_listings_cache": False, **(storage_options or {})}
|
|
37
|
+
return UPath(str(root), **options)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def is_remote(path: StorePath) -> bool:
|
|
41
|
+
return not isinstance(path, Path)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def publish(partial: Path, final: StorePath) -> None:
|
|
45
|
+
"""Move a validated local partial file to its final place.
|
|
46
|
+
|
|
47
|
+
Local: an atomic rename in the same directory. Remote: one upload — an object
|
|
48
|
+
is only visible once its PUT (or multipart upload) completes, so a reader never
|
|
49
|
+
sees a half-written file.
|
|
50
|
+
"""
|
|
51
|
+
if is_remote(final):
|
|
52
|
+
final.fs.put_file(str(partial), final.path)
|
|
53
|
+
partial.unlink(missing_ok=True)
|
|
54
|
+
else:
|
|
55
|
+
partial.replace(final)
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: eumdac-store
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Robust EUMDAC downloader with integrity validation, quarantine, and a ducats-backed catalog, to a directory or a bucket
|
|
5
|
+
Project-URL: Repository, https://github.com/TUW-GEO/eumdac-store
|
|
6
|
+
Author-email: TU Wien <remote.sensing@geo.tuwien.ac.at>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE.txt
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: ducats>=0.2
|
|
14
|
+
Requires-Dist: eumdac<5,>=4.0
|
|
15
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
16
|
+
Requires-Dist: pydantic>=2.0
|
|
17
|
+
Requires-Dist: python-dotenv>=1.0
|
|
18
|
+
Requires-Dist: pyyaml>=6.0
|
|
19
|
+
Requires-Dist: requests>=2.31
|
|
20
|
+
Requires-Dist: urllib3>=2.0
|
|
21
|
+
Provides-Extra: s3
|
|
22
|
+
Requires-Dist: s3fs>=2024.6; extra == 's3'
|
|
23
|
+
Requires-Dist: universal-pathlib>=0.2; extra == 's3'
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# eumdac-store
|
|
27
|
+
|
|
28
|
+
Robust EUMDAC downloader — Python API + CLI, to a directory or a bucket.
|
|
29
|
+
|
|
30
|
+
What it adds on top of plain `eumdac download`:
|
|
31
|
+
|
|
32
|
+
- **Rate-limit awareness** — parallel downloads clamped to EUMDAC's 10-connection ceiling.
|
|
33
|
+
- **Retries with backoff** — one budget shared across network errors and integrity failures.
|
|
34
|
+
- **Integrity validation** — each download checked against EUMDAC's size + ZIP magic before publishing. MD5 is skipped (EUMDAC publishes wrong MD5 metadata).
|
|
35
|
+
- **Atomic publish** — partials are unlinked on failure, so a reader never sees half-files.
|
|
36
|
+
- **Persistent-corruption quarantine** — a product that exhausts the retry budget gets a `.quarantine` sidecar (JSON `kind`: `missing` / `size` / `zip`) and is skipped until cooloff.
|
|
37
|
+
- **Skip what we already have** — a [ducats](https://github.com/TUW-GEO/ducats) catalog synced from the store (a directory or a bucket) decides presence, re-synced after each run.
|
|
38
|
+
|
|
39
|
+
## Install
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install eumdac-store # a local directory as the store
|
|
43
|
+
pip install "eumdac-store[s3]" # also object storage (s3://…)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
For development: `uv sync --extra s3`.
|
|
47
|
+
|
|
48
|
+
## CLI
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Download the last day, skipping what the catalog already has.
|
|
52
|
+
# Product wiring is required and comes from a config file — ASCAT SZF values ship in examples/ascat_szf.yaml:
|
|
53
|
+
eumdac-store download --config examples/ascat_szf.yaml --days 1 \
|
|
54
|
+
--download-root-dir /data/eumdac
|
|
55
|
+
|
|
56
|
+
# Explicit window:
|
|
57
|
+
eumdac-store download --config examples/ascat_szf.yaml \
|
|
58
|
+
--start 2026-01-01T00:00 --end 2026-01-02T00:00 ...
|
|
59
|
+
|
|
60
|
+
# Either bound is optional: --start alone fetches everything since then (up to
|
|
61
|
+
# now); --end alone fetches everything up to it (open lower bound).
|
|
62
|
+
# E.g. backfill the whole collection up to a date:
|
|
63
|
+
eumdac-store download --config examples/ascat_szf.yaml --end 2026-01-01T00:00 ...
|
|
64
|
+
|
|
65
|
+
# List without downloading:
|
|
66
|
+
eumdac-store list --config examples/ascat_szf.yaml --days 1 ...
|
|
67
|
+
|
|
68
|
+
# Re-sync the catalog from the store (no EUMDAC calls):
|
|
69
|
+
eumdac-store sync --config examples/ascat_szf.yaml ...
|
|
70
|
+
|
|
71
|
+
# Sync status + quarantine sidecar count:
|
|
72
|
+
eumdac-store status --config examples/ascat_szf.yaml ...
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Credentials: `EUMDAC_KEY` / `EUMDAC_SECRET` in the environment or `.env`, or EUMETSAT's own `credentials.json` (`{"consumer_key": …, "consumer_secret": …}`) placed at `$XDG_CONFIG_HOME/eumdac-store/credentials.json` (default `~/.config/eumdac-store/credentials.json`). Env vars win over the file. Config also via `$EUMDAC_STORE_CONFIG` or `EUMDAC_STORE_*` env vars; per-flag options win.
|
|
76
|
+
|
|
77
|
+
## Object storage (S3)
|
|
78
|
+
|
|
79
|
+
`download_root_dir` may be a URL instead of a directory; the local filesystem stays the default.
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
uv sync --extra s3 # universal-pathlib + s3fs
|
|
83
|
+
eumdac-store download --config examples/ascat_szf.yaml --days 1 \
|
|
84
|
+
--download-root-dir s3://tuw-ascat-l1b/eumdac
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Credentials and endpoint come from the usual AWS sources (`AWS_PROFILE`, `AWS_SHARED_CREDENTIALS_FILE`, `AWS_ACCESS_KEY_ID`/`AWS_SECRET_ACCESS_KEY`, `AWS_ENDPOINT_URL`) or from `storage_options` (YAML, or `EUMDAC_STORE_STORAGE_OPTIONS` as JSON), passed to fsspec as is, e.g. `{"profile": "tuw-ascat-l1b", "endpoint_url": "https://objects.eodc.eu"}`.
|
|
88
|
+
|
|
89
|
+
What differs from a local root:
|
|
90
|
+
|
|
91
|
+
- **Publish** — the zip is downloaded and validated on local disk (a temp dir), then uploaded in one PUT; an object is only visible once its upload completes, so readers never see a half file.
|
|
92
|
+
- **Catalog** — local, as for every root (see Configuration); ducats's `glob()` lists the bucket through the same fsspec filesystem (registered with DuckDB), so presence still comes from what is really stored.
|
|
93
|
+
- **Quarantine** — sidecars are small objects next to the zips; their age is the object's LastModified (or the sidecar's own `quarantined_at`).
|
|
94
|
+
- **Retention** — set a lifecycle rule on the bucket; eumdac-store never deletes.
|
|
95
|
+
|
|
96
|
+
## Gaps
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
eumdac-store gaps --config examples/ascat_szf.yaml --days 2 # exit 4 if any
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Lists the store and reports breaks in each group's time chain (groups: the pattern's named groups other than `start`/`end`, e.g. `sat`; or `gap_group_cols`). Consecutive files chain when the next starts `gap_min_seconds`..`gap_max_seconds` after the last one ends (defaults 0..1 s, as SZF). `--start`/`--end` keep the gaps that begin in that window.
|
|
103
|
+
|
|
104
|
+
## Airflow
|
|
105
|
+
|
|
106
|
+
The fetch DAG that keeps a rolling archive filled (e.g. `s3://tuw-ascat-l1b/szf/`) lives in its own repository, **eumdac-fetch**. It installs this package from PyPI at a pinned version, so no image is needed.
|
|
107
|
+
|
|
108
|
+
## Python API
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
from eumdac_store import EumdacStore, StoreConfig
|
|
112
|
+
|
|
113
|
+
store = EumdacStore(StoreConfig.from_yaml("examples/ascat_szf.yaml",
|
|
114
|
+
download_root_dir="/data/eumdac",
|
|
115
|
+
))
|
|
116
|
+
result = store.download(days=1) # or start=, end=, specific_dates=
|
|
117
|
+
print(result) # downloaded=… skipped_present=… skipped_quarantined=… failed=…
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Product fields are **required** (no defaults); pass them inline to `StoreConfig(...)` to skip the YAML.
|
|
121
|
+
|
|
122
|
+
## Configuration
|
|
123
|
+
|
|
124
|
+
| Field | Required | Default | Meaning |
|
|
125
|
+
|-------|----------|---------|---------|
|
|
126
|
+
| `collection_id` | **yes** | — | EUMDAC collection to search |
|
|
127
|
+
| `product_name` | **yes** | — | ducats catalog table name (must be a valid identifier)
|
|
128
|
+
| `filename_glob` | **yes** | — | Which files in `<product_name>/` the catalog globs |
|
|
129
|
+
| `filename_pattern` | **yes** | — | Regex for ducats's `RegexExtractor`; `(?P<start>...)` is required, `(?P<end>...)` optional (absent → `end_ts` NULL), other named groups become categorical columns |
|
|
130
|
+
| `download_root_dir` | **yes** | — | EUMDAC data root: `<product_name>/` per product lives here. A directory, or a URL such as `s3://bucket/prefix` (see Object storage) |
|
|
131
|
+
| `storage_options` | no | `{}` | fsspec options for a URL root |
|
|
132
|
+
| `catalog_file` | no | derived | DuckDB catalog path (see below) |
|
|
133
|
+
| `max_workers` | no | 10 | Parallel downloads (hard-clamped to 10) |
|
|
134
|
+
| `max_retries` | no | 3 | Retry budget per file |
|
|
135
|
+
| `quarantine_cooloff_hours` | no | 2.0 | How long a quarantine sidecar suppresses refetch |
|
|
136
|
+
|
|
137
|
+
`product_dir` is `<download_root_dir>/<product_name>/`. The catalog is a local cache of that listing, rebuilt from scratch on every sync, so it is kept out of the data: `catalog_path` is `catalog_file` if set, else `$XDG_CACHE_HOME/eumdac-store/<root>/catalog.duckdb` (`<root>` is the absolute directory without its leading `/`, or `bucket/prefix` for a URL). Losing it costs one sync. A catalog left at `<download_root_dir>/catalog.duckdb` by earlier versions is deleted after the first successful sync, so a copy of the root never carries a stale one.
|
|
138
|
+
|
|
139
|
+
Products under one `download_root_dir` share one catalog (one DuckDB file, one table per `product_name`).
|
|
140
|
+
|
|
141
|
+
Copy `examples/ascat_szf.yaml` for another product. A missing required field is a hard validation error.
|
|
142
|
+
|
|
143
|
+
## Tests
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
uv run pytest # no network — a fake EUMDAC DataStore backs every test
|
|
147
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
eumdac_store/__init__.py,sha256=FQrtGJYvqZYB0BGGe68WciDxIyUIPLZxTqKMJIPETWM,351
|
|
2
|
+
eumdac_store/_version.py,sha256=HGBlVvZpQ8N2kh1n_LY5PM4s9ljcIgdbOCgXN-uFje4,520
|
|
3
|
+
eumdac_store/catalog.py,sha256=XLXdLkjxuW3GU-YhRfcSI6m9kOpHgRxCfr4_42qe5XQ,4357
|
|
4
|
+
eumdac_store/cli.py,sha256=CNIbE1j1ntpYeENrL4GDOYEYu9f8ZI64D-D4pAyjf90,6737
|
|
5
|
+
eumdac_store/config.py,sha256=GlzDsuhXmkFbBE9kYmB8pZ6l3TcufdXPoD94LWlS7XE,3916
|
|
6
|
+
eumdac_store/fetcher.py,sha256=R3NOdF5VKVnAYTmGEpvXkYKthEktgmuMecOdUQj2uyc,12806
|
|
7
|
+
eumdac_store/integrity.py,sha256=Z6_sJNfTCnA2BLA9AifaZpj6TX_mNT_0tGTBQYuDauo,3622
|
|
8
|
+
eumdac_store/service.py,sha256=bp6DClCR4AsoPpYaEocSvc2ZaF8-kY4QZLHhtcbfG_4,4986
|
|
9
|
+
eumdac_store/storage.py,sha256=qmNduWU6SHaO-glKID6jbUZyBXfx99PdyKs83qVYYqQ,2010
|
|
10
|
+
eumdac_store-0.4.0.dist-info/METADATA,sha256=-VxDG5ZApepepQraQXwJOloqY1TbexUqZ5P0p4-ygik,7871
|
|
11
|
+
eumdac_store-0.4.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
12
|
+
eumdac_store-0.4.0.dist-info/entry_points.txt,sha256=aSGImV2lmG19WWgSXGrX8Tfpj2YkFC_oCJMUeYNLZoY,55
|
|
13
|
+
eumdac_store-0.4.0.dist-info/licenses/LICENSE.txt,sha256=TcbxUEcaXgrW-eWznBQ7tGxLiYRTpwYXMuBV51d1Y5k,1074
|
|
14
|
+
eumdac_store-0.4.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TU Wien
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|