A modular Python framework for end‑to‑end conflict forecasting: data ingestion, transformation, drift monitoring, model and ensemble management, evaluation, reconciliation, mapping, reporting, packaging, and artifact governance.
Acknowledgements
Table of Contents
- Conceptual Overview
- High‑Level Architecture
- Core Pipeline Stages
- Managers (Orchestration Layer)
- Modules (Functional Layer)
- Data Layer & Querysets
- Evaluation & Metrics
- Reconciliation (Hierarchical Consistency)
- Reporting & Mapping
- CLI & Argument System
- Configuration & Partitioning
- Package Management
- Logging & Monitoring
- Development Workflow
- Quick Start
- FAQ
1. Conceptual Overview
The pipeline transforms raw geo‑temporal data into validated, reconciled, and documented forecasts. Key features include:
- Deterministic data preparation (queryset-driven, drift-checked)
- Strict naming & artifact conventions
- Partition-aware evaluation (calibration/validation/forecasting)
- Multi-model ensembling & hierarchical reconciliation
- Automated HTML reporting and spatial visualization
- Reproducible configuration merging and logging
- Optional integration with Weights & Biases (WandB) and prediction store
2. High‑Level Architecture
┌────────────────────────────────────────┐
│ ConfigurationManager │
│ (deployment + hyperparameters + meta) │
└───────────────┬────────────────────────┘
│
┌────────────────────────▼─────────────────────────┐
│ ViewsDataLoader │
│ Queryset → Raw Fetch → Drift Check │
│ → Partition Slice │
└───────────────┬──────────────────────────────────┘
│ DataFrame (month_id, entity_id)
▼
┌─────────────────────────────────────────┐
│ ForecastingModelManager (thin façade) │
│ Routes to independently testable stages│
│ │
│ ┌─────────────┐ ┌──────────────────┐ │
│ │TrainingStage│ │ EvaluationStage │ │
│ └─────────────┘ └──────────────────┘ │
│ ┌───────────────┐ ┌────────────────┐ │
│ │ForecastingStage│ │ReportingStage │ │
│ └───────────────┘ └────────────────┘ │
│ ┌───────────────────────┐ │
│ │ PredictionIOManager │ │
│ └───────────────────────┘ │
└────────────┬────────────────────────────┘
│ Predictions
▼
┌────────────────────────┐
│ ReconciliationModule │
│ (Country ↔ Priogrid) │
└────────────┬───────────┘
│ Reconciled Predictions
▼
┌───────────────────────────┐
│ Reporting & Mapping │
│ HTML, Tables, Choropleths │
└───────────────────────────┘
Architecture note (April 2026):
ForecastingModelManagerhas been decomposed from a 3049-LOC monolith into a ~1960-LOC thin façade that delegates to 5 independently testable stage classes. Each stage receives a frozen context object (immutable dataclass) rather than reaching into the manager's internals.ModelPathManagerhas been relocated frommanagers/todata/to fix dependency inversion. All existing import paths continue to work via re-export shims. See ADR-045 for the full design rationale.
3. Core Pipeline Stages
| Stage | Output | Key Component |
|---|---|---|
| Data Fetch | Partitioned feature/target frame | ViewsDataLoader |
| Train | Artifact (model file) | TrainingStage (via ForecastingModelManager / EnsembleManager) |
| Evaluate | Metrics + eval predictions | EvaluationStage (via ForecastingModelManager) |
| Forecast | Future horizon predictions | ForecastingStage (via ForecastingModelManager) |
| Reconcile | Grid ↔ country consistency | ReconciliationModule |
| Report | HTML summaries | ReportingStage (via ForecastingModelManager) |
| Package | Poetry-compliant project | PackageManager |
4. Managers (Orchestration Layer)
| Manager / Stage | Purpose |
|---|---|
| ModelPathManager | Path + artifact resolution for a model (canonical location: data/) |
| ModelManager | Abstract training/evaluation/forecast flow control |
| ForecastingModelManager | Thin façade — routes to pipeline stages below |
| EvaluationStage | Metrics orchestration (DF + PF paths, step mappings, evaluator integration) |
| ReportingStage | Forecast + evaluation HTML report generation |
| ForecastingStage | Post-processing, validation, and persistence of forecast predictions |
| TrainingStage | Training log creation and WandB alerts |
| PredictionIOManager | Save/load predictions, evaluations, and evaluation tables |
| EnsemblePathManager | Paths for multi-model ensemble |
| EnsembleManager | Aggregation + optional reconciliation |
| ExtractorPathManager | External raw data ingestion paths |
| ExtractorManager | Download → preprocess → save for external datasets |
| PostprocessorPathManager | Downstream transformation stage paths |
| PostprocessorManager | Read → transform → validate → save |
| PackageManager | Create/validate Poetry packages |
| ConfigurationManager | Merge + validate layered configuration |
Each stage receives an immutable frozen context object and is independently unit-testable. See ADR-045 for architecture details.
5. Modules (Functional Layer)
| Module | Role |
|---|---|
| dataloaders | Partition-aware data retrieval + drift detection |
| transformations | Dataset transformation undo/management (extracted to views-reporting, ADR-054) |
| reconciliation | Hierarchical grid ↔ country alignment (extracted to views-reporting, ADR-054) |
| reports | Tailwind-styled HTML evaluation/forecast report generation (extracted to views-reporting, ADR-054) |
| mapping | Static + interactive choropleth maps (extracted to views-reporting, ADR-054) |
| visualizations | Historical line graphs & distribution plots (extracted to views-reporting, ADR-054) |
| logging | Central logging configuration injection |
| statistics | Posterior distribution analysis & forecast reconciliation (extracted to views-reporting, ADR-054) |
| wandb | Alerts, artifact logging, run lifecycle |
| model validation | Structural & logical integrity checks (sniffer pattern, ADR-041) |
| ensemble validation | Structural & logical integrity checks |
5.1 Intermediate Modules
| Module | Role |
|---|---|
| cli | CLI parsing and validation |
| dataset | Spatio-temporal dataset handler with country and priogrid level support |
6. Data Layer & Querysets
- Querysets define feature/target extraction logic + transformation chains.
- MultiIndex structure:
(month_id, entity_id)for time-spatial operations. - Data types normalized (
float64for numeric integrity). - Partitions defined via month ranges (train/test or forecast horizon).
7. Evaluation & Metrics
Evaluation produces:
- Step-wise metrics (per forecast horizon)
- Month-wise metrics (temporal slices)
- Time-series metrics (sequence performance trajectory)
Conflict type auto-inferred from target tokens (sb / ns / os). Files named per ADR conventions (artifact/output naming).
8. Reconciliation (Hierarchical Consistency)
Ensures priogrid sums align with authoritative country totals while preserving relative spatial pattern and zero inflation. Parallelizable across countries × time × targets. Integrated into ensembles or model forecast postprocessing.
9. Reporting & Mapping
| Component | Feature |
|---|---|
| ReportModule | Headings, paragraphs, Markdown, tables, images, grids |
| MappingModule | Country & priogrid choropleths (static + interactive animation) |
| Templates | Forecast + evaluation report skeletons |
| CSS | Tailwind subset embedded for portability |
Reports embed:
- Metrics tables
- Key–value configuration summaries
- Spatial animations (Plotly)
- Artifact provenance (timestamps, versions)
10. CLI & Argument System
Dataclass-driven (ForecastingModelArgs):
- Flags:
--train,--evaluate,--forecast,--report,--sweep,--prediction_store,--monthly - Validation prevents illegal combinations (e.g., evaluate with forecasting run type).
- Monthly shortcut auto-configures production cycle.
11. Configuration & Partitioning
ConfigurationManager merges:
- Deployment
- Hyperparameters
- Meta
- Partition dictionary
- Runtime overrides (highest priority)
Forecast partitions dynamically adjusted by override_timestep. Validation enforces structural integrity and target specification.
12. Package Management
PackageManager:
- Validates naming (
organization-prefix-*) - Creates Poetry skeleton (Python version constraint)
- Adds dependencies (including views-pipeline-core)
- Fetches latest release (tags or GitHub API)
- Runs
poetry check
13. Logging & Monitoring
- YAML-driven configuration (handlers, levels, formatters).
- Dedicated model/ensemble logging directories.
- Standard separation: main log, error log.
- WandB alerts for stage transitions, failures, reconciliation completeness.
14. Development Workflow
| Task | Command |
|---|---|
| Run model | ./run.sh --run_type calibration --train --evaluate --report --saved |
| Run ensemble | ./run.sh --ensemble hybrid_lynx --forecast --report |
| Generate report only | Use --evaluate --report or --forecast --report |
Refer to documentation/development_guidelines.md for coding standards and docstring_guidelines.md for formatting.
15. Quick Start
-
Run
build_model_scaffold.pyorbuild_ensemble_scaffold.pyfound in theviews-modelsrepository. -
Update
config_maturity.py,config_hyperparameters.py,config_queryset.py,config_meta.py. (Sources scaffolded before ADR-057 carryconfig_deployment.pyinstead; either is read while the transition window is open, and the new name wins when both are present.) -
Run calibration:
python main.py --run_type calibration --train --evaluate --report
-
Run forecasting:
python main.py --run_type forecasting --train --forecast --report
-
View artifacts:
models/<name>/artifacts/
16. FAQ
| Question | Answer |
|---|---|
| Do I need WandB? | Optional; disable notifications to run offline. |
| Can I reconcile single-model forecasts? | Yes—apply ReconciliationModule manually after forecast stage. |
| How do I add a new transformation? | Register callable in transformation mapping and ensure replay compatibility. |
| Are forecasts stored transformed or raw? | Temporarily reversed to raw scale before saving (pending ADR finalization). |
| Can I aggregate probabilistic outputs? | Current ensemble aggregation expects scalar or single-element lists. |
Metadata
Release files for views_pipeline_core 3.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| views_pipeline_core-3.4.0.tar.gz | 375.4 kB | Without provenance | Details for views_pipeline_core-3.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| views_pipeline_core-3.4.0-py3-none-any.whl | Python 3 | none | any | Details for views_pipeline_core-3.4.0-py3-none-any.whl |
Total release size: 829.3 kB
Release files / views_pipeline_core-3.4.0.tar.gz
| Download URL | views_pipeline_core-3.4.0.tar.gz |
|---|---|
| Size | 375.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
806c4410caab4562ca1542af604808eca4532c079c800fb3b7615171b1156599
|
|
BLAKE2b-256 checksum How to use checksums |
a7adc97b9c852ae1f0ee93ad848422c22b85e783c71fdedc79c186521604e2ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.11.17 Linux/7.0.0-1017-azure
|
Release files / views_pipeline_core-3.4.0-py3-none-any.whl
| Download URL | views_pipeline_core-3.4.0-py3-none-any.whl |
|---|---|
| Size | 454.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c560396f1ff880ea76da7365e75bbb6a49d4fa58b4518ab57021240cb29e553e
|
|
BLAKE2b-256 checksum How to use checksums |
30e6bd0b4c2e40dd0db7f47624ad517ed898397e42c7a98e249eeb60b13067dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.5.1 CPython/3.11.17 Linux/7.0.0-1017-azure
|
Security for views_pipeline_core 3.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.