Metadata-Version: 2.5
Name: eumdac-store
Version: 0.5.1
Summary: Download EUMDAC products into a directory or an S3 bucket, with integrity checks, quarantine and a ducats catalog
Project-URL: Repository, https://github.com/TUW-GEO/eumdac-store
Author-email: TU Wien <remote.sensing@geo.tuwien.ac.at>
License-Expression: MIT
License-File: LICENSE.txt
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.12
Requires-Dist: ducats>=0.2
Requires-Dist: eumdac<5,>=4.0
Requires-Dist: pydantic-settings>=2.0
Requires-Dist: pydantic>=2.0
Requires-Dist: python-dotenv>=1.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: requests>=2.31
Requires-Dist: s3fs>=2024.6
Requires-Dist: universal-pathlib>=0.2
Requires-Dist: urllib3>=2.0
Description-Content-Type: text/markdown

# eumdac-store

Keeps a directory or S3 bucket filled with an EUMDAC collection. `eumdac`
downloads what you ask for; eumdac-store is for running the same window again
and again (e.g. hourly):

- Skips what is already stored, using a [ducats](https://github.com/TUW-GEO/ducats) catalog of the store.
- Checks each file's size and zip structure (EUMDAC's MD5s are wrong) and retries bad ones.
- Quarantines a file that stays corrupt, so later runs don't keep fetching it.
- Never leaves partial files under their final name.
- Stays within EUMDAC's limit of 10 parallel connections.
- Reports gaps in the stored time series (`gaps`).

```bash
pip install eumdac-store
```

## Usage

```bash
eumdac-store download --config examples/ascat_szf.yaml --days 1 --download-root-dir /data/eumdac
eumdac-store download --config examples/ascat_szf.yaml --start 2026-01-01T00:00 --end 2026-01-02T00:00
eumdac-store list     --config examples/ascat_szf.yaml --days 1
eumdac-store sync     --config examples/ascat_szf.yaml
eumdac-store status   --config examples/ascat_szf.yaml
eumdac-store gaps     --config examples/ascat_szf.yaml --days 2   # exit 4 if any
```

```python
from eumdac_store import EumdacStore, StoreConfig

store = EumdacStore(StoreConfig.from_yaml("examples/ascat_szf.yaml", download_root_dir="/data/eumdac"))
store.download(days=1)
```

Credentials: `EUMDAC_KEY` and `EUMDAC_SECRET` (environment or `.env`), or
`~/.config/eumdac-store/credentials.json` with `consumer_key` and
`consumer_secret`.

## Configuration

See `examples/`. Every field can also be set as `EUMDAC_STORE_<FIELD>`.

| Field | Default | |
|---|---|---|
| `collection_id` | required | EUMDAC collection |
| `product_name` | required | subdirectory and catalog table |
| `filename_glob` | required | files the catalog lists |
| `filename_pattern` | required | regex with `(?P<start>…)`, optional `(?P<end>…)` and group columns |
| `filename_ts_format` | `%Y%m%d%H%M%S` | |
| `download_root_dir` | required | a directory or `s3://bucket/prefix` |
| `storage_options` | `{}` | fsspec options for a URL root, e.g. `endpoint_url` |
| `catalog_file` | `$XDG_CACHE_HOME/eumdac-store/<root>/catalog.duckdb` | |
| `max_workers` | 10 | at most 10 |
| `max_retries` | 3 | per file |
| `quarantine_cooloff_hours` | 2.0 | |
| `gap_group_cols` | the pattern's groups | for `gaps` |
| `gap_min_seconds`, `gap_max_seconds` | 0, 1 | allowed gap between consecutive files |

For S3, credentials come from the usual AWS environment variables or
`storage_options`. eumdac-store never deletes; use a bucket lifecycle rule
for retention.

## Development

```bash
uv sync
uv run pytest
```
