A pipeline for processing environmental time series data from monitoring networks. The system performs corrections, quality control, infilling, aggregation, and derivation operations on meteorological and hydrological measurements.
This pipeline processes time series data through a metadata-driven approach:
- Fetches metadata from the FDRI Metadata API to build a dependency graph of datasets
- Processes datasets in topological order, ensuring dependencies are satisfied
- Applies operations corrections > quality control > infilling > aggregation/derivation
- Writes results to S3 storage as partitioned parquet files
The processor CLI is invoked using:
python -m dritimeseriesprocessor ...Use one of four (mutually exclusive) processing modes, or the utility command:
-
Explicit:
from-selection- Individual sets of processing arguments
python -m dritimeseriesprocessor from-selection --network NETWORK [--lookback DURATION | --start-date YYYY-MM-DD] [--end-date YYYY-MM-DD] --selection SITE VARIABLE PERIODICITY [--selection SITE2 VARIABLE2 PERIODICITY2 ...]Example:
python -m dritimeseriesprocessor from-selection --network cosmos --lookback P2D --selection cosmos-alic1 TA PT30M --selection cosmos-bunny PA PT30M --selection cosmos-bunny PRECIP P1D
-
Cross-product:
from-cross-product- Bulk processing across processing dimensions
python -m dritimeseriesprocessor from-cross-product --network NETWORK [--lookback DURATION | --start-date YYYY-MM-DD] [--end-date YYYY-MM-DD] [--sites SITE1 SITE2 ...] [--variables VAR1 VAR2 ...] [--periodicities PER1 PER2 ...]Example:
python -m dritimeseriesprocessor from-cross-product --network cosmos --lookback P2D --sites cosmos-alic1 cosmos-bunny --variables TA PA --periodicities PT30M
-
From datasets:
from-datasets- Request one or more datasets directly by their metadata API ID
- Works for both
TimeSeriesDatasetandObservationDatasetrecords - Does not require
--network
python -m dritimeseriesprocessor from-datasets [--lookback DURATION | --start-date YYYY-MM-DD] [--end-date YYYY-MM-DD] --datasets DATASET_ID [DATASET_ID2 ...]Example:
python -m dritimeseriesprocessor from-datasets --datasets flux-plynl-processed --start-date 2024-08-14 --end-date 2024-08-15
-
Historic:
historic- Processes everything for a network's sites over each site's full operating dates, one calendar year at a time
- No dataset or date options: start and end dates come from each site's metadata (end date is today if still open)
- Optionally pass
--sitesto limit the run to a specific set of sites
python -m dritimeseriesprocessor historic --network NETWORK [--sites SITE [SITE ...]]
Example:
python -m dritimeseriesprocessor historic --network cosmos --sites cosmos-alic1
-
List sites:
list-sites- Writes a JSON array of active site IDs for a network to
/tmp/sites.json - Sites not open during the requested date window are excluded
- Pass
--historicinstead of any date arguments to list every site the network has ever had - Optionally pass
--sitesto limit the result to a specific set of sites (still checked against the network and date window)
python -m dritimeseriesprocessor list-sites --network NETWORK [--sites SITE [SITE ...]] [--historic | [--lookback DURATION | --start-date YYYY-MM-DD] [--end-date YYYY-MM-DD]]
Example:
python -m dritimeseriesprocessor list-sites --network cosmos --lookback P2D
- Writes a JSON array of active site IDs for a network to
See CLI Usage for more info.
This is for active development on the processing package itself.
git clone https://github.com/NERC-CEH/dri-timeseries-processor.git
cd dri-timeseries-processoruv sync
source .venv/bin/activate
Build the Docker container to set up LocalStack (local AWS services):
docker compose up -dThis initialises:
- LocalStack S3 buckets with sample data
- Prometheus Pushgateway for metrics (accessible at
localhost:9091)
Run make help to list all available targets. The most commonly used ones:
| Command | Description |
|---|---|
make qa |
Format, lint, type check, and test |
make test |
Run tests |
make ruff |
Run ruff format and lint checks |
make type-check |
Type check with pyright |
make docker-build |
Build the Docker image locally |
make docker-run |
Run the Docker image locally |
make install-hooks |
Configure git to use .githooks/ |
Test data is automatically loaded into LocalStack S3 on container initialization.
VSCode has a useful test runner, allowing running and debugging of all tests within the repository. To allow VSCode
to detect the tests, use the Configure Tests option accessed either via the help menu (select "Show All Commands"
and type "Configure Tests" in the search bar), or via the test runner panel and select the "Configure Tests" button
if it is available. To configure the tests, select pytest as the test runner framework and testing as the
directory containing the tests.
Run the following to set up the pre-commit hooks:
make install-hooksThe hook runs ruff format --check and ruff check to prevent commits that are not formatted correctly or have errors.
The hook intentionally does not alter files, but tells you which command to run.
This project follows Semantic Versioning (major.minor.patch). The patch component is used
as an auto-incrementing build number: a local pre-push git hook bumps it on every push that doesn't already include
a version change. Install the hook once per clone with make install-hooks. major and minor are bumped by hand
with make bump-minor or make bump-major when you want a new release line. Every merge to production automatically
builds the production Docker image, tags the commit, and creates a GitHub release.
See Versioning and Releases for the full flow, examples, and the workflows involved.
Configuration is environment-aware, loading from different sources based on the environment variable:
- Local:
__assets__/env.cfgfile - Staging/Production: Environment variables directly
Required configuration keys:
AWS_DEFAULT_REGION,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEYmetadata_api_urlendpoint_url(LocalStack only)
The pipeline exports Prometheus metrics to a Pushgateway:
- Pipeline timing: Total runtime, per-operation timings
- Success/failure counts: Datasets processed successfully or failed
- Data availability: Datasets with no data available
Locally accessible at http://localhost:9091
Available in docs folder.