views-datafactory 1.9.0__tar.gz
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.
- views_datafactory-1.9.0/.gitignore +62 -0
- views_datafactory-1.9.0/LICENSE +21 -0
- views_datafactory-1.9.0/PKG-INFO +528 -0
- views_datafactory-1.9.0/README.md +492 -0
- views_datafactory-1.9.0/pyproject.toml +98 -0
- views_datafactory-1.9.0/src/datafactory_adapters/ARCHITECTURE.md +54 -0
- views_datafactory-1.9.0/src/datafactory_adapters/__init__.py +38 -0
- views_datafactory-1.9.0/src/datafactory_adapters/_conservation.py +95 -0
- views_datafactory-1.9.0/src/datafactory_adapters/_reconciliation.py +92 -0
- views_datafactory-1.9.0/src/datafactory_adapters/_validation.py +39 -0
- views_datafactory-1.9.0/src/datafactory_adapters/feature_frame.py +25 -0
- views_datafactory-1.9.0/src/datafactory_adapters/grid_from_feature_frame.py +89 -0
- views_datafactory-1.9.0/src/datafactory_adapters/grid_to_country_month.py +169 -0
- views_datafactory-1.9.0/src/datafactory_adapters/grid_to_dataframe.py +176 -0
- views_datafactory-1.9.0/src/datafactory_compilation/ARCHITECTURE.md +63 -0
- views_datafactory-1.9.0/src/datafactory_compilation/__init__.py +39 -0
- views_datafactory-1.9.0/src/datafactory_compilation/aggregation.py +64 -0
- views_datafactory-1.9.0/src/datafactory_compilation/compilation_config.py +97 -0
- views_datafactory-1.9.0/src/datafactory_compilation/conservation.py +36 -0
- views_datafactory-1.9.0/src/datafactory_compilation/grid_compilation.py +352 -0
- views_datafactory-1.9.0/src/datafactory_compilation/output.py +85 -0
- views_datafactory-1.9.0/src/datafactory_compilation/preflight.py +61 -0
- views_datafactory-1.9.0/src/datafactory_compilation/pregridded_compilation.py +291 -0
- views_datafactory-1.9.0/src/datafactory_consolidation/ARCHITECTURE.md +58 -0
- views_datafactory-1.9.0/src/datafactory_consolidation/__init__.py +28 -0
- views_datafactory-1.9.0/src/datafactory_consolidation/consolidation_result.py +27 -0
- views_datafactory-1.9.0/src/datafactory_consolidation/consolidators/__init__.py +32 -0
- views_datafactory-1.9.0/src/datafactory_consolidation/consolidators/acled.py +462 -0
- views_datafactory-1.9.0/src/datafactory_consolidation/consolidators/ucdp.py +524 -0
- views_datafactory-1.9.0/src/datafactory_consolidation/event_store.py +67 -0
- views_datafactory-1.9.0/src/datafactory_consolidation/tagging.py +46 -0
- views_datafactory-1.9.0/src/datafactory_harvester/ARCHITECTURE.md +103 -0
- views_datafactory-1.9.0/src/datafactory_harvester/__init__.py +37 -0
- views_datafactory-1.9.0/src/datafactory_harvester/event_validation.py +372 -0
- views_datafactory-1.9.0/src/datafactory_harvester/harvest_runner.py +72 -0
- views_datafactory-1.9.0/src/datafactory_harvester/pipeline_runner.py +125 -0
- views_datafactory-1.9.0/src/datafactory_harvester/snapshot_storage.py +117 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/__init__.py +36 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/_ucdp_common.py +34 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/acled.py +743 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/gaul_admin.py +567 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/ghsbuilts.py +271 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/ghspop.py +267 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/priogrid_static.py +359 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/shdi.py +625 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/ucdp_annual.py +616 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/ucdp_candidate.py +419 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/ucdp_dot9.py +407 -0
- views_datafactory-1.9.0/src/datafactory_harvester/sources/vdem.py +350 -0
- views_datafactory-1.9.0/src/datafactory_harvester/validation.py +74 -0
- views_datafactory-1.9.0/src/datafactory_http/__init__.py +10 -0
- views_datafactory-1.9.0/src/datafactory_http/retry.py +102 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/ARCHITECTURE.md +62 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/__init__.py +51 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/cell_generator.py +137 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/grid_config.py +107 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/land_mask.py +62 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/parity_validation.py +176 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/shapefile_harvester.py +174 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/shapefile_reader.py +125 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/spatiotemporal.py +66 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/temporal_config.py +78 -0
- views_datafactory-1.9.0/src/datafactory_priogrid/temporal_generator.py +65 -0
- views_datafactory-1.9.0/src/datafactory_provenance/ARCHITECTURE.md +61 -0
- views_datafactory-1.9.0/src/datafactory_provenance/__init__.py +81 -0
- views_datafactory-1.9.0/src/datafactory_provenance/constants.py +3 -0
- views_datafactory-1.9.0/src/datafactory_provenance/digests_and_ledgers.py +370 -0
- views_datafactory-1.9.0/src/datafactory_provenance/health.py +310 -0
- views_datafactory-1.9.0/src/datafactory_provenance/pipeline_lock.py +200 -0
- views_datafactory-1.9.0/src/datafactory_provenance/registry.py +92 -0
- views_datafactory-1.9.0/src/datafactory_provenance/skip.py +212 -0
- views_datafactory-1.9.0/src/datafactory_provenance/source_registry.py +466 -0
- views_datafactory-1.9.0/src/datafactory_query/ARCHITECTURE.md +60 -0
- views_datafactory-1.9.0/src/datafactory_query/__init__.py +36 -0
- views_datafactory-1.9.0/src/datafactory_query/africa_me_gaul_pgids.json +1 -0
- views_datafactory-1.9.0/src/datafactory_query/africa_me_legacy_pgids.json +1 -0
- views_datafactory-1.9.0/src/datafactory_query/backends_npy.py +90 -0
- views_datafactory-1.9.0/src/datafactory_query/backends_zarr.py +259 -0
- views_datafactory-1.9.0/src/datafactory_query/coverage.py +64 -0
- views_datafactory-1.9.0/src/datafactory_query/dataset.py +263 -0
- views_datafactory-1.9.0/src/datafactory_query/defaults.py +101 -0
- views_datafactory-1.9.0/src/datafactory_query/land_gaul_pgids.json +1 -0
- views_datafactory-1.9.0/src/datafactory_query/land_pgids.json +1 -0
- views_datafactory-1.9.0/src/datafactory_query/output_format.py +52 -0
- views_datafactory-1.9.0/src/datafactory_query/regions.py +293 -0
- views_datafactory-1.9.0/src/datafactory_query/temporal.py +115 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/ARCHITECTURE.md +68 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/__init__.py +33 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/builders/__init__.py +32 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/builders/acled_v1.py +213 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/builders/ghsbuilts_v1.py +351 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/builders/ghspop_v1.py +471 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/builders/shdi_v1.py +389 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/builders/ucdp_v1.py +437 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/builders/vdem_v1.py +419 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/profiles.py +169 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/raster_io.py +49 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/spatial_distribution.py +203 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/spatial_weights.py +207 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/survivorship.py +108 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/temporal.py +111 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/temporal_distribution.py +295 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/viewpoint_config.py +124 -0
- views_datafactory-1.9.0/src/datafactory_viewpoint/viewpoint_result.py +33 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Data cache (disposable — rebuildable from provenance)
|
|
2
|
+
# Ignore contents but track README
|
|
3
|
+
data/*
|
|
4
|
+
!data/README.md
|
|
5
|
+
data/*/
|
|
6
|
+
|
|
7
|
+
# Python
|
|
8
|
+
__pycache__/
|
|
9
|
+
*.py[cod]
|
|
10
|
+
*.egg-info/
|
|
11
|
+
dist/
|
|
12
|
+
build/
|
|
13
|
+
.eggs/
|
|
14
|
+
|
|
15
|
+
# Virtual environments
|
|
16
|
+
.venv/
|
|
17
|
+
venv/
|
|
18
|
+
|
|
19
|
+
# IDE
|
|
20
|
+
.idea/
|
|
21
|
+
.vscode/
|
|
22
|
+
*.swp
|
|
23
|
+
*.swo
|
|
24
|
+
|
|
25
|
+
# OS
|
|
26
|
+
.DS_Store
|
|
27
|
+
Thumbs.db
|
|
28
|
+
|
|
29
|
+
# mypy
|
|
30
|
+
.mypy_cache/
|
|
31
|
+
|
|
32
|
+
# pytest
|
|
33
|
+
.pytest_cache/
|
|
34
|
+
|
|
35
|
+
# ruff
|
|
36
|
+
.ruff_cache/
|
|
37
|
+
|
|
38
|
+
# Generated HTML (status page output)
|
|
39
|
+
status.html
|
|
40
|
+
|
|
41
|
+
# Operational artifacts (regenerable)
|
|
42
|
+
provenance/
|
|
43
|
+
reports/audit/
|
|
44
|
+
reports/audit_acled/
|
|
45
|
+
reports/audit_ghsbuilts/
|
|
46
|
+
reports/audit_ghspop/
|
|
47
|
+
reports/audit_vdem/
|
|
48
|
+
reports/presentation/
|
|
49
|
+
|
|
50
|
+
# Graphify output (generated knowledge graph artifacts)
|
|
51
|
+
graphify-out/
|
|
52
|
+
|
|
53
|
+
# Credentials (never commit secrets)
|
|
54
|
+
.env
|
|
55
|
+
.env.*
|
|
56
|
+
credentials.toml
|
|
57
|
+
|
|
58
|
+
# Session
|
|
59
|
+
resume_session.md
|
|
60
|
+
|
|
61
|
+
# Claude Code
|
|
62
|
+
.claude/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simon Polichinel von der Maase
|
|
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.
|
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: views-datafactory
|
|
3
|
+
Version: 1.9.0
|
|
4
|
+
Summary: Data factory for the VIEWS conflict forecasting platform — provenance, harvesting, consolidation, viewpoint construction, compilation, and assembly.
|
|
5
|
+
Project-URL: Homepage, https://github.com/views-platform/views-datafactory
|
|
6
|
+
Project-URL: Repository, https://github.com/views-platform/views-datafactory
|
|
7
|
+
Project-URL: Issues, https://github.com/views-platform/views-datafactory/issues
|
|
8
|
+
Author-email: Simon Polichinel von der Maase <simmaa@prio.org>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: acled,conflict-forecasting,data-pipeline,priogrid,provenance,ucdp,zarr
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Classifier: Typing :: Typed
|
|
20
|
+
Requires-Python: >=3.12
|
|
21
|
+
Requires-Dist: aiohttp<4,>=3.9
|
|
22
|
+
Requires-Dist: fsspec<2025,>=2023.9
|
|
23
|
+
Requires-Dist: imagecodecs>=2024.1
|
|
24
|
+
Requires-Dist: matplotlib<4,>=3.8
|
|
25
|
+
Requires-Dist: numpy<3,>=1.26
|
|
26
|
+
Requires-Dist: pandas<3,>=2.0
|
|
27
|
+
Requires-Dist: pyarrow<20,>=14
|
|
28
|
+
Requires-Dist: pyshp<3,>=2.3
|
|
29
|
+
Requires-Dist: requests<3,>=2.28
|
|
30
|
+
Requires-Dist: shapely<3,>=2.0
|
|
31
|
+
Requires-Dist: tifffile>=2024.1
|
|
32
|
+
Requires-Dist: views-frames<2,>=1.0
|
|
33
|
+
Requires-Dist: xarray<2026,>=2024.1
|
|
34
|
+
Requires-Dist: zarr<3,>=2.16
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
<div style="width: 100%; max-width: 1500px; height: 400px; overflow: hidden; position: relative;">
|
|
38
|
+
<img src="https://github.com/user-attachments/assets/1ec9e217-508d-4b10-a41a-08dface269c7" alt="VIEWS Twitter Header" style="position: absolute; top: -50px; width: 100%; height: auto;">
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
# views-datafactory
|
|
42
|
+
|
|
43
|
+
**Data factory for the VIEWS conflict forecasting platform — harvesting, consolidation, viewpoint building, grid compilation, and query.**
|
|
44
|
+
|
|
45
|
+
Part of the [VIEWS Platform](https://github.com/views-platform) ecosystem.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Table of Contents
|
|
50
|
+
|
|
51
|
+
- [Overview](#overview)
|
|
52
|
+
- [Role in VIEWS Platform](#role-in-views-platform)
|
|
53
|
+
- [Architecture](#architecture)
|
|
54
|
+
- [Packages](#packages)
|
|
55
|
+
- [Project Structure](#project-structure)
|
|
56
|
+
- [Installation](#installation)
|
|
57
|
+
- [Quick Start](#quick-start)
|
|
58
|
+
- [Strategic Documents](#strategic-documents)
|
|
59
|
+
- [Where to Find What](#where-to-find-what)
|
|
60
|
+
- [Contributing](#contributing)
|
|
61
|
+
- [License](#license)
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Overview
|
|
66
|
+
|
|
67
|
+
views-datafactory provides the data foundation for conflict forecasting in the VIEWS platform. It handles the full lifecycle of spatiotemporal conflict data — from raw ingestion through to compiled grid arrays ready for model consumption.
|
|
68
|
+
|
|
69
|
+
The system is designed as a **graph of independent nodes**, not a linear pipeline. Source nodes (harvesters) produce data independently. Compilation edges transform source data into consumer-specific formats. Consumer nodes read compiled outputs. This architecture ensures that adding a new data source or output format never requires changing existing components.
|
|
70
|
+
|
|
71
|
+
### Key Capabilities
|
|
72
|
+
|
|
73
|
+
- **Auditable data harvesting** — UCDP (annual, candidate, .9), ACLED, GHS-POP, GHS-BUILT-S, V-Dem, SHDI, PRIO-GRID static, and GAUL admin boundaries, all with schema validation, drift detection, and JSONL provenance ledgers
|
|
74
|
+
- **PRIO-GRID spatial backbone** — pure-numpy generation of the standard 259,200-cell global grid at 0.5° resolution, validated cell-by-cell against the official PRIO reference shapefile
|
|
75
|
+
- **Temporal backbone** with VIEWS month_id adapters (epoch: January 1980)
|
|
76
|
+
- **Vintage-aware consolidation** — lossless, append-only, bitemporal event store from all three UCDP sources with content-digest deduplication
|
|
77
|
+
- **Configurable viewpoints** — survivorship strategies (annual_wins, dot9_wins), temporal distribution (even_split, ceil_split), production filtering via named profiles
|
|
78
|
+
- **Deterministic compilation** of viewpoint output onto the spatiotemporal grid as npy arrays
|
|
79
|
+
- **Consumer adapters** — grid-to-DataFrame and grid-to-FeatureFrame conversions for downstream consumers
|
|
80
|
+
- **End-to-end provenance** — every value in a compiled grid is traceable back to the specific source records and compilation config that produced it
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Role in VIEWS Platform
|
|
85
|
+
|
|
86
|
+
views-datafactory is the upstream data provider for the VIEWS forecasting pipeline. It produces the compiled grid arrays that models consume for training and inference.
|
|
87
|
+
|
|
88
|
+
### Integration with Other Repositories
|
|
89
|
+
|
|
90
|
+
- **[views-metric-lab](https://github.com/views-platform/views-metric-lab):** First consumer — uses compiled grids for evaluation metric research and model stress-testing
|
|
91
|
+
- **[views-hydranet](https://github.com/views-platform/views-hydranet):** Will consume compiled grids for production neural forecasting (HydraNet v2)
|
|
92
|
+
- **[views-pipeline-core](https://github.com/views-platform/views-pipeline-core):** Central pipeline infrastructure — may depend on views-datafactory for standardised data access
|
|
93
|
+
- **[views-evaluation](https://github.com/views-platform/views-evaluation):** May consume compiled grids for benchmarking
|
|
94
|
+
|
|
95
|
+
### Data Flow
|
|
96
|
+
|
|
97
|
+
**No layer imports from the layer above or below.** The filesystem is the API between layers. Each dashed line below represents zero code coupling — only a file path convention. This is enforced by an import-enforcement test that AST-scans every package.
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
UCDP/GED API ──→ datafactory_harvester ──→ data/raw/ucdp_*/*.parquet
|
|
101
|
+
ACLED API ──────→ datafactory_harvester ──→ data/raw/acled/*.parquet
|
|
102
|
+
(event sources)
|
|
103
|
+
─ ─ ─ ─ ─ ─ ─ ─ filesystem boundary
|
|
104
|
+
│
|
|
105
|
+
datafactory_consolidation ──→ data/consolidated/*.parquet
|
|
106
|
+
│
|
|
107
|
+
─ ─ ─ ─ ─ ─ ─ ─ filesystem boundary
|
|
108
|
+
│
|
|
109
|
+
datafactory_viewpoint ──→ data/viewpoint/*.parquet
|
|
110
|
+
│
|
|
111
|
+
─ ─ ─ ─ ─ ─ ─ ─ filesystem boundary
|
|
112
|
+
│
|
|
113
|
+
PRIO-GRID ──────→ datafactory_priogrid ─┐ │
|
|
114
|
+
PRIO-GRID API ──→ datafactory_harvester ──→ data/raw/priogrid_static/
|
|
115
|
+
FAO GAUL API ───→ datafactory_harvester ──→ data/raw/gaul_admin/
|
|
116
|
+
JRC GHSL ───────→ datafactory_harvester ──→ data/raw/ghspop/ + ghsbuilts/
|
|
117
|
+
V-Dem ──────────→ datafactory_harvester ──→ data/raw/vdem/
|
|
118
|
+
GDL SHDI ───────→ datafactory_harvester ──→ data/raw/shdi/
|
|
119
|
+
(GHS-POP, GHS-BUILT-S, V-Dem, SHDI skip consolidation — single releases)
|
|
120
|
+
│ │
|
|
121
|
+
datafactory_compilation ──→ data/compiled/grid.npy [T,H,W,C]
|
|
122
|
+
│
|
|
123
|
+
─ ─ ─ ─ ─ ─ ─ ─ filesystem boundary
|
|
124
|
+
│
|
|
125
|
+
assemble_grid.py ──→ data/assembled/grid.npy [T,H,W,C]
|
|
126
|
+
(compiled UCDP + ACLED + GHS-POP + GHS-BUILT-S + V-Dem + SHDI + static + admin)
|
|
127
|
+
│
|
|
128
|
+
─ ─ ─ ─ ─ ─ ─ ─ filesystem boundary
|
|
129
|
+
│
|
|
130
|
+
datafactory_query ──→ FeatureFrame / DataFrame
|
|
131
|
+
(load_dataset: region, time, feature subsetting)
|
|
132
|
+
│
|
|
133
|
+
generate_consumer_data.py ──→ {run_type}_viewser_df.parquet
|
|
134
|
+
(factory → VIEWSER vocabulary)
|
|
135
|
+
│
|
|
136
|
+
┌───────────┴───────────┐
|
|
137
|
+
│ Consumers │
|
|
138
|
+
│ (metric lab, │
|
|
139
|
+
│ hydranet) │
|
|
140
|
+
└───────────────────────┘
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Not all paths traverse all layers. GHS-POP, GHS-BUILT-S, V-Dem, and SHDI skip consolidation (single releases; ADR-029, ADR-034, ADR-035, ADR-036).
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Architecture
|
|
149
|
+
|
|
150
|
+
The architecture is a **graph**, not a pipeline. Each node is a self-contained package with explicit dependencies:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
Layer 0 — Foundation (no internal imports):
|
|
154
|
+
datafactory_provenance Content digests, JSONL ledger operations
|
|
155
|
+
datafactory_http HTTP request utilities: retry with exponential backoff
|
|
156
|
+
|
|
157
|
+
Layer 1 — Source nodes (import provenance + http):
|
|
158
|
+
datafactory_priogrid PRIO-GRID spatial + temporal backbone
|
|
159
|
+
datafactory_harvester Data ingestion with pluggable sources
|
|
160
|
+
|
|
161
|
+
Layer 2 — Consolidation (imports provenance, reads harvester files):
|
|
162
|
+
datafactory_consolidation Lossless event store from raw snapshots
|
|
163
|
+
|
|
164
|
+
Layer 3 — Viewpoint (imports provenance, reads consolidation files):
|
|
165
|
+
datafactory_viewpoint Opinionated materialized views
|
|
166
|
+
|
|
167
|
+
Layer 4 — Compilation (imports provenance + priogrid, reads viewpoint files):
|
|
168
|
+
datafactory_compilation Viewpoint output → populated grid arrays
|
|
169
|
+
|
|
170
|
+
Consumer-facing (no datafactory_* imports):
|
|
171
|
+
datafactory_adapters Grid → DataFrame, Grid → FeatureFrame
|
|
172
|
+
|
|
173
|
+
Assembly (script, not package — combines compiled sources):
|
|
174
|
+
scripts/assemble_grid.py Compiled UCDP + ACLED + GHS-POP + GHS-BUILT-S + V-Dem + SHDI + static + admin → [T,H,W,C]
|
|
175
|
+
|
|
176
|
+
Consumer entry point (imports priogrid + adapters, reads assembled files):
|
|
177
|
+
datafactory_query load_dataset() — region/time/feature subsetting, npy or zarr
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Dependency rules (ADR-012):**
|
|
181
|
+
- `datafactory_provenance` imports nothing internal
|
|
182
|
+
- `datafactory_priogrid` and `datafactory_harvester` import only from `datafactory_provenance` (and `datafactory_http` for network operations)
|
|
183
|
+
- `datafactory_consolidation` imports only from `datafactory_provenance`; reads harvester output as **files**
|
|
184
|
+
- `datafactory_viewpoint` imports only from `datafactory_provenance`; reads consolidation output as **files**
|
|
185
|
+
- `datafactory_compilation` imports `datafactory_provenance` and `datafactory_priogrid`; reads viewpoint output as **files**
|
|
186
|
+
- `datafactory_adapters` imports nothing from `datafactory_*`; sits alongside the graph, not inside it
|
|
187
|
+
- `datafactory_query` imports `datafactory_priogrid` and `datafactory_adapters`; reads assembled output as **files** (npy or zarr)
|
|
188
|
+
- Independence is enforced by an import-enforcement test that AST-scans every package
|
|
189
|
+
|
|
190
|
+
### Design Principles
|
|
191
|
+
|
|
192
|
+
| Principle | Description |
|
|
193
|
+
|-----------|-------------|
|
|
194
|
+
| **Graph, not pipeline** | Sources don't know about consumers. Compilation edges are consumer-driven. |
|
|
195
|
+
| **Provenance all the way through** | Every node that produces data writes a JSONL ledger entry. Mission-critical. |
|
|
196
|
+
| **Config-driven, fail-loud** | Frozen dataclasses with `__post_init__` validation. No silent defaults. |
|
|
197
|
+
| **npy now, zarr-ready** | Dimension order: `[T, H, W, C]` (time, height, width, channels). Coordinate arrays shipped alongside data. |
|
|
198
|
+
| **Screaming architecture** | Package and file names communicate domain, not programming taxonomy. |
|
|
199
|
+
|
|
200
|
+
### Filesystem Boundaries and Data Contracts
|
|
201
|
+
|
|
202
|
+
Layers are decoupled by the filesystem, not by imports. Each layer computes SHA-256 of its input file (`source_digest`) and output file (`output_digest`), recording both in its JSONL ledger. This creates a cryptographic provenance chain from raw API response to consumer parquet — any tampering or re-run is detectable by comparing digests across ledgers.
|
|
203
|
+
|
|
204
|
+
| Boundary | Writer | Reader | File Path | Format | Key Columns / Shape |
|
|
205
|
+
|----------|--------|--------|-----------|--------|---------------------|
|
|
206
|
+
| Harvest → Consolidation | `harvest_ucdp.py` | `consolidate_ucdp.py` | `data/raw/ucdp_*/` | Parquet | `id`, `date_start`, `date_end`, `best`, `low`, `high`, `type_of_violence` |
|
|
207
|
+
| Consolidation → Viewpoint | `consolidate_ucdp.py` | `build_viewpoint.py` | `data/consolidated/` | Parquet | All harvest columns + `_source_type`, `_source_version`, `_ingested_at` |
|
|
208
|
+
| Viewpoint → Compilation | `build_viewpoint.py` | `compile_grid.py` | `data/viewpoint/*.parquet` | Parquet | `latitude`, `longitude`, `date_month`, `best`, `type_of_violence` |
|
|
209
|
+
| Compilation → Assembly | `compile_grid.py` | `assemble_grid.py` | `data/compiled/` | npy `[T,H,W,C]` | `grid.npy` + `pgids.npy` + `time_steps.npy` + `feature_names.json` |
|
|
210
|
+
| Assembly → Query/Consumer | `assemble_grid.py` | `load_dataset()` | `data/assembled/` or `.zarr` | npy or zarr | `grid.npy [T,H,W,C]` with same sidecars |
|
|
211
|
+
|
|
212
|
+
### Consumer Contract
|
|
213
|
+
|
|
214
|
+
The `generate_consumer_data.py` script produces parquet files for VIEWS training scripts (`purple_alien`, `white_ranger`, etc.). Column names are the factory's source names — consumer-side renaming (if any) is the model's responsibility via `config_queryset.py`.
|
|
215
|
+
|
|
216
|
+
| Column | Meaning |
|
|
217
|
+
|--------|---------|
|
|
218
|
+
| `ged_sb_best` | State-based conflict fatalities (best estimate) |
|
|
219
|
+
| `ged_ns_best` | Non-state conflict fatalities |
|
|
220
|
+
| `ged_os_best` | One-sided violence fatalities |
|
|
221
|
+
| `gaul0_code` | Country identifier (GAUL Level 0) |
|
|
222
|
+
| `row`, `col` | Grid position (derived from `priogrid_gid`) |
|
|
223
|
+
|
|
224
|
+
Training partitions use VIEWS month_id encoding (epoch: January 1980):
|
|
225
|
+
- **Calibration:** train 121–444, test 445–492
|
|
226
|
+
- **Validation:** train 121–492, test 493–540
|
|
227
|
+
- **Forecasting:** train 121–current, test current+1 to current+36
|
|
228
|
+
|
|
229
|
+
Output: `{calibration,validation,forecasting}_viewser_df.parquet` with MultiIndex `(month_id, priogrid_gid)`.
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
233
|
+
## Packages
|
|
234
|
+
|
|
235
|
+
| Package | Layer | Purpose | Status |
|
|
236
|
+
|---------|-------|---------|--------|
|
|
237
|
+
| `datafactory_provenance` | 0 | Content digests, JSONL ledgers, file locking, rotation | Done |
|
|
238
|
+
| `datafactory_http` | 0 | HTTP request utilities: retry with exponential backoff | Done |
|
|
239
|
+
| `datafactory_priogrid` | 1 | PRIO-GRID spatial + temporal backbone (259,200 cells, monthly) | Done |
|
|
240
|
+
| `datafactory_harvester` | 1 | Data harvesting: UCDP (annual/candidate/.9), ACLED, GHS-POP, GHS-BUILT-S, V-Dem, SHDI, PRIO-GRID static, GAUL admin | Done |
|
|
241
|
+
| `datafactory_consolidation` | 2 | Lossless, vintage-aware consolidation of UCDP and ACLED sources | Done |
|
|
242
|
+
| `datafactory_viewpoint` | 3 | Opinionated views: survivorship, temporal distribution, profiles | Done |
|
|
243
|
+
| `datafactory_compilation` | 4 | Viewpoint output → grid npy with coordinate sidecars | Done |
|
|
244
|
+
| `datafactory_adapters` | — | Consumer-facing: grid → DataFrame, grid → FeatureFrame | Done |
|
|
245
|
+
| `datafactory_query` | — | Consumer entry point: `load_dataset()`, region/time subsetting, dual npy/zarr backend | Done |
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## Project Structure
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
views-datafactory/
|
|
253
|
+
├── pyproject.toml # hatchling + uv
|
|
254
|
+
├── CLAUDE.md # AI assistant context
|
|
255
|
+
├── .github/workflows/ci.yml # CI: ruff + mypy + pytest
|
|
256
|
+
├── src/
|
|
257
|
+
│ ├── datafactory_provenance/ # Layer 0 — digests + ledgers
|
|
258
|
+
│ │ ├── digests_and_ledgers.py
|
|
259
|
+
│ │ ├── constants.py VIEWS_EPOCH_YEAR (shared constant)
|
|
260
|
+
│ │ └── source_registry.py SourceEntry, PIPELINE_SOURCES
|
|
261
|
+
│ ├── datafactory_http/ # Layer 0 — HTTP retry utilities
|
|
262
|
+
│ │ └── retry.py request_with_retry (shared)
|
|
263
|
+
│ ├── datafactory_priogrid/ # Layer 1 — PRIO-GRID backbone
|
|
264
|
+
│ │ ├── grid_config.py GridConfig (spatial params)
|
|
265
|
+
│ │ ├── temporal_config.py TemporalConfig (year/month range)
|
|
266
|
+
│ │ ├── cell_generator.py generate_grid, pgid_to_latlon
|
|
267
|
+
│ │ ├── temporal_generator.py generate_time_steps, VIEWS month_id
|
|
268
|
+
│ │ ├── spatiotemporal.py SpatioTemporalGrid (composition)
|
|
269
|
+
│ │ ├── parity_validation.py validate_parity (vs. reference shapefile)
|
|
270
|
+
│ │ ├── shapefile_reader.py PyShpReader (pluggable Protocol)
|
|
271
|
+
│ │ └── shapefile_harvester.py fetch_shapefile (reference data)
|
|
272
|
+
│ ├── datafactory_harvester/ # Layer 1 — data ingestion
|
|
273
|
+
│ │ ├── event_validation.py ValidationResult, compare_snapshots
|
|
274
|
+
│ │ ├── snapshot_storage.py save_event_snapshot, archive_snapshot
|
|
275
|
+
│ │ └── sources/ Source plugin registry
|
|
276
|
+
│ │ ├── ucdp_annual.py UCDP/GED Annual source
|
|
277
|
+
│ │ ├── ucdp_candidate.py UCDP/GED Candidate Monthly source
|
|
278
|
+
│ │ ├── ucdp_dot9.py UCDP/GED .9 Consolidated Monthly
|
|
279
|
+
│ │ ├── acled.py ACLED event data (year-by-year)
|
|
280
|
+
│ │ ├── ghspop.py GHS-POP R2023A (JRC GHSL raster)
|
|
281
|
+
│ │ ├── ghsbuilts.py GHS-BUILT-S R2023A (JRC GHSL raster)
|
|
282
|
+
│ │ ├── vdem.py V-Dem v16 democracy indicators
|
|
283
|
+
│ │ ├── shdi.py SHDI subnational human development
|
|
284
|
+
│ │ ├── priogrid_static.py PRIO-GRID static covariates
|
|
285
|
+
│ │ └── gaul_admin.py GAUL 2024 admin boundaries
|
|
286
|
+
│ ├── datafactory_consolidation/ # Layer 2 — lossless event stores
|
|
287
|
+
│ │ ├── event_store.py Append-only Parquet store
|
|
288
|
+
│ │ ├── tagging.py tag_table (shared metadata tagging)
|
|
289
|
+
│ │ └── consolidators/
|
|
290
|
+
│ │ ├── ucdp.py Three-source UCDP consolidation
|
|
291
|
+
│ │ └── acled.py ACLED event consolidation
|
|
292
|
+
│ ├── datafactory_viewpoint/ # Layer 3 — opinionated views
|
|
293
|
+
│ │ ├── survivorship.py Strategy registry (annual_wins, dot9_wins)
|
|
294
|
+
│ │ ├── temporal_distribution.py Strategy registry (even_split, ceil_split)
|
|
295
|
+
│ │ ├── profiles.py Named presets (production_parity)
|
|
296
|
+
│ │ ├── raster_io.py read_geotiff (shared GeoTIFF reader)
|
|
297
|
+
│ │ ├── temporal.py interpolate_temporal (shared interpolation)
|
|
298
|
+
│ │ └── builders/
|
|
299
|
+
│ │ ├── ucdp_v1.py UCDP viewpoint builder
|
|
300
|
+
│ │ ├── ghspop_v1.py GHS-POP viewpoint builder
|
|
301
|
+
│ │ ├── ghsbuilts_v1.py GHS-BUILT-S viewpoint builder
|
|
302
|
+
│ │ ├── vdem_v1.py V-Dem viewpoint builder
|
|
303
|
+
│ │ └── shdi_v1.py SHDI viewpoint builder
|
|
304
|
+
│ ├── datafactory_compilation/ # Layer 4 — grid compilation
|
|
305
|
+
│ │ ├── compilation_config.py CompilationConfig
|
|
306
|
+
│ │ ├── grid_compilation.py compile_grid (event sources)
|
|
307
|
+
│ │ ├── pregridded_compilation.py compile_pregridded (raster sources)
|
|
308
|
+
│ │ ├── output.py write_compilation_output (shared writer)
|
|
309
|
+
│ │ └── aggregation.py count, sum_field, max_field strategies
|
|
310
|
+
│ ├── datafactory_adapters/ # Consumer-facing conversions
|
|
311
|
+
│ │ ├── feature_frame.py FeatureFrame dataclass
|
|
312
|
+
│ │ ├── grid_to_dataframe.py Grid → pandas DataFrame
|
|
313
|
+
│ │ └── grid_from_feature_frame.py FeatureFrame → Grid (inverse)
|
|
314
|
+
│ └── datafactory_query/ # Consumer entry point
|
|
315
|
+
│ ├── dataset.py load_dataset (npy + zarr backends)
|
|
316
|
+
│ ├── regions.py Region name → PRIO-GRID cell set
|
|
317
|
+
│ └── temporal.py Flexible time range parsing
|
|
318
|
+
├── tests/ # ~2000 tests
|
|
319
|
+
├── scripts/ # Operational scripts
|
|
320
|
+
│ ├── harvest_ucdp.py UCDP harvest (annual + candidate + .9)
|
|
321
|
+
│ ├── harvest_acled.py ACLED event harvest (year-by-year)
|
|
322
|
+
│ ├── harvest_ghspop.py GHS-POP raster harvest (12 epochs)
|
|
323
|
+
│ ├── harvest_ghsbuilts.py GHS-BUILT-S raster harvest (12 epochs)
|
|
324
|
+
│ ├── harvest_priogrid.py PRIO-GRID static covariates
|
|
325
|
+
│ ├── harvest_shapefile.py PRIO-GRID shapefile download
|
|
326
|
+
│ ├── harvest_gaul.py GAUL admin boundary harvest + spatial join
|
|
327
|
+
│ ├── consolidate_ucdp.py Three-source UCDP consolidation
|
|
328
|
+
│ ├── build_viewpoint.py Viewpoint from profile
|
|
329
|
+
│ ├── compile_grid.py Event source grid compilation
|
|
330
|
+
│ ├── compile_acled.py ACLED grid compilation
|
|
331
|
+
│ ├── run_acled_pipeline.py ACLED end-to-end pipeline
|
|
332
|
+
│ ├── run_ghspop_pipeline.py GHS-POP end-to-end pipeline
|
|
333
|
+
│ ├── run_ghsbuilts_pipeline.py GHS-BUILT-S end-to-end pipeline
|
|
334
|
+
│ ├── harvest_vdem.py V-Dem CSV harvest
|
|
335
|
+
│ ├── compile_vdem.py V-Dem grid compilation
|
|
336
|
+
│ ├── run_vdem_pipeline.py V-Dem end-to-end pipeline
|
|
337
|
+
│ ├── harvest_shdi.py SHDI subnational HDI harvest
|
|
338
|
+
│ ├── run_shdi_pipeline.py SHDI end-to-end pipeline
|
|
339
|
+
│ ├── assemble_grid.py UCDP + ACLED + GHS-POP + GHS-BUILT-S + V-Dem + SHDI + static + admin
|
|
340
|
+
│ ├── generate_consumer_data.py Factory → VIEWSER parquet for training
|
|
341
|
+
│ ├── export_dataframe.py Grid → DataFrame export
|
|
342
|
+
│ ├── export_zarr.py Grid → zarr store (HTTP-servable)
|
|
343
|
+
│ ├── preflight.py Pre-pipeline disk + env checks
|
|
344
|
+
│ ├── check_health.py System health check
|
|
345
|
+
│ ├── refresh_pipeline.sh Full pipeline orchestrator (14 steps)
|
|
346
|
+
│ ├── visualize_audit.py Data audit visualization
|
|
347
|
+
│ └── ... verify_parity, verify_remote, etc.
|
|
348
|
+
├── docs/ # ADRs, CICs, protocols, standards
|
|
349
|
+
│ ├── ADRs/ 10 constitutional + 39 project-specific
|
|
350
|
+
│ ├── CICs/ 34 active class intent contracts
|
|
351
|
+
│ ├── contributor_protocols/ carbon, silicon, hardened
|
|
352
|
+
│ └── standards/ logging & observability
|
|
353
|
+
├── reports/ # Strategic documents + audit outputs
|
|
354
|
+
│ ├── rd_roadmap11.md R&D roadmap (v11)
|
|
355
|
+
│ ├── product_development_plan11.md Product development plan (v11)
|
|
356
|
+
│ ├── technical_risk_register.md Technical risk register (ADR-020)
|
|
357
|
+
│ └── dot9_investigation/ .9 data stream research findings
|
|
358
|
+
├── provenance/ # JSONL ledgers (gitignored)
|
|
359
|
+
└── data/ # Raw + compiled data (gitignored)
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
## Installation
|
|
365
|
+
|
|
366
|
+
**As a consumer** (you want `load_dataset()` and the adapters):
|
|
367
|
+
|
|
368
|
+
```bash
|
|
369
|
+
pip install views-datafactory
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
**As a developer** (you want the tests, scripts, and docs):
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Clone the repository
|
|
376
|
+
git clone https://github.com/views-platform/views-datafactory.git
|
|
377
|
+
cd views-datafactory
|
|
378
|
+
|
|
379
|
+
# Install with uv
|
|
380
|
+
uv sync
|
|
381
|
+
|
|
382
|
+
# Verify
|
|
383
|
+
uv run pytest -v
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
> **Note:** This project uses [uv](https://github.com/astral-sh/uv) for dependency management and [hatchling](https://hatch.pypa.io/) as the build backend.
|
|
387
|
+
|
|
388
|
+
### Prerequisites — who needs credentials?
|
|
389
|
+
|
|
390
|
+
| You want to... | Credentials needed |
|
|
391
|
+
|----------------|--------------------|
|
|
392
|
+
| Develop / run the test suite | **None.** A bare checkout runs the full suite. |
|
|
393
|
+
| Read served data (remote zarr) | An entry in `~/.netrc` for the VIEWS data server — ask the data factory administrator for the password. |
|
|
394
|
+
| Run the harvest pipeline yourself | `UCDP_API_TOKEN`, `ACLED_USERNAME`/`ACLED_PASSWORD`, `GDL_API_TOKEN` (free registrations with the respective providers). GHS-POP, GHS-BUILT-S, V-Dem, PRIO-GRID static, and GAUL need no credentials. |
|
|
395
|
+
|
|
396
|
+
Setup instructions for all of these: **[docs/guides/credential_setup.md](docs/guides/credential_setup.md)**. New to the whole platform and just want to run a model? Start at **[docs/guides/model_consumer_quickstart.md](docs/guides/model_consumer_quickstart.md)**.
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
## Quick Start
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
# Full pipeline (automated): runs all 14 steps end-to-end
|
|
404
|
+
bash scripts/refresh_pipeline.sh
|
|
405
|
+
|
|
406
|
+
# Or run individual steps:
|
|
407
|
+
uv run python scripts/harvest_ucdp.py # fetch all UCDP sources
|
|
408
|
+
uv run python scripts/harvest_acled.py # fetch ACLED events
|
|
409
|
+
uv run python scripts/harvest_ghspop.py # fetch GHS-POP rasters
|
|
410
|
+
uv run python scripts/harvest_ghsbuilts.py # fetch GHS-BUILT-S rasters
|
|
411
|
+
uv run python scripts/consolidate_ucdp.py # three-source UCDP consolidation
|
|
412
|
+
uv run python scripts/build_viewpoint.py # apply production_parity profile
|
|
413
|
+
uv run python scripts/compile_grid.py # UCDP → grid.npy
|
|
414
|
+
uv run python scripts/compile_acled.py # ACLED → grid.npy
|
|
415
|
+
uv run python scripts/run_ghspop_pipeline.py # GHS-POP viewpoint + compile
|
|
416
|
+
uv run python scripts/run_ghsbuilts_pipeline.py # GHS-BUILT-S viewpoint + compile
|
|
417
|
+
uv run python scripts/run_vdem_pipeline.py # V-Dem viewpoint + compile
|
|
418
|
+
uv run python scripts/run_shdi_pipeline.py # SHDI viewpoint + compile
|
|
419
|
+
uv run python scripts/assemble_grid.py \ # assemble all sources into one grid
|
|
420
|
+
--acled-grid data/compiled/acled \ # (each --*-grid flag is optional;
|
|
421
|
+
--ghspop-grid data/compiled/ghspop \ # omitted sources are silently skipped,
|
|
422
|
+
--ghsbuilts-grid data/compiled/ghsbuilts \ # producing a partial grid)
|
|
423
|
+
--vdem-grid data/compiled/vdem \
|
|
424
|
+
--shdi-grid data/compiled/shdi
|
|
425
|
+
uv run python scripts/generate_consumer_data.py # factory → VIEWSER training parquets
|
|
426
|
+
|
|
427
|
+
# Visualize the assembled grid
|
|
428
|
+
uv run python scripts/visualize_audit.py # 15 audit plots → reports/audit/
|
|
429
|
+
|
|
430
|
+
# Export for downstream consumers
|
|
431
|
+
uv run python scripts/export_zarr.py # grid → zarr store (HTTP-servable)
|
|
432
|
+
uv run python scripts/export_dataframe.py # grid → DataFrame CSV
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
```python
|
|
436
|
+
# Programmatic usage — load_dataset() is the primary consumer entry point
|
|
437
|
+
from datafactory_query import load_dataset
|
|
438
|
+
|
|
439
|
+
# Load Ethiopia 2020-2024 as FeatureFrame (temporal + geographic subsetting)
|
|
440
|
+
ff = load_dataset(region="Ethiopia", start="2020", end="2024")
|
|
441
|
+
|
|
442
|
+
# Load global land cells as DataFrame
|
|
443
|
+
df = load_dataset(region="land", output_format="dataframe")
|
|
444
|
+
|
|
445
|
+
# Load from the remote zarr store (requires ~/.netrc — see docs/guides/credential_setup.md)
|
|
446
|
+
from datafactory_query.defaults import DEFAULT_REMOTE
|
|
447
|
+
|
|
448
|
+
ff = load_dataset(
|
|
449
|
+
region="africa_me",
|
|
450
|
+
start="2020",
|
|
451
|
+
data_dir=DEFAULT_REMOTE.zarr_url,
|
|
452
|
+
)
|
|
453
|
+
```
|
|
454
|
+
|
|
455
|
+
```python
|
|
456
|
+
# Low-level access — direct npy loading
|
|
457
|
+
from datafactory_adapters import FeatureFrame, grid_to_dataframe
|
|
458
|
+
import json, numpy as np
|
|
459
|
+
|
|
460
|
+
data = np.load("data/assembled/grid.npy", mmap_mode="r")
|
|
461
|
+
pgids = np.load("data/assembled/pgids.npy")
|
|
462
|
+
time_steps = np.load("data/assembled/time_steps.npy")
|
|
463
|
+
feature_names = json.loads(open("data/assembled/feature_names.json").read())
|
|
464
|
+
|
|
465
|
+
df = grid_to_dataframe(data, pgids, time_steps, feature_names, month_id_epoch=1980)
|
|
466
|
+
ff = FeatureFrame.from_grid(data, pgids, time_steps, feature_names)
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
471
|
+
## Strategic Documents
|
|
472
|
+
|
|
473
|
+
The `reports/` directory contains living documents that define the project's direction:
|
|
474
|
+
|
|
475
|
+
- **[R&D Roadmap](reports/rd_roadmap11.md)** — Research questions, hypotheses, data agenda, milestones. Focuses on what must be *discovered*.
|
|
476
|
+
- **[Product Development Plan](reports/product_development_plan11.md)** — Users, requirements, architecture, release plan. Focuses on what must be *built*.
|
|
477
|
+
- **[Technical Risk Register](reports/technical_risk_register.md)** — 298 concerns tracked, 258 resolved, 37 open with trigger conditions (ADR-020).
|
|
478
|
+
- **[.9 Investigation](reports/dot9_investigation/)** — Empirical findings on UCDP .9 data stream characteristics.
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## Where to Find What
|
|
483
|
+
|
|
484
|
+
This system separates information by ownership and change frequency (ADR-003). Different questions have different authoritative sources:
|
|
485
|
+
|
|
486
|
+
| If you need to know… | Look in… | Why there |
|
|
487
|
+
|----------------------|----------|-----------|
|
|
488
|
+
| How to set up credentials, get data, run a model, or operate the server | [`docs/guides/`](docs/guides/) — how-to guides (see its README for an index) | Task-oriented walkthroughs |
|
|
489
|
+
| What data sources we use, who publishes them, what license/format/coverage | `docs/sources/` — catalog cards | Upstream facts, rarely change |
|
|
490
|
+
| Why we chose a specific source, what alternatives we considered | `docs/ADRs/` — source selection ADRs (028, 029) | One-time decisions |
|
|
491
|
+
| How a derived feature is constructed (aggregation, survivorship, distribution) | Viewpoint CICs (`docs/CICs/Viewpoint*.md`) and profile configs (`src/datafactory_viewpoint/profiles.py`) | Volatile — changes as research evolves |
|
|
492
|
+
| What SLO, env vars, or feature list a source has | `src/datafactory_provenance/source_registry.py` — `SourceEntry` | Operational config, changes on redeploy |
|
|
493
|
+
| Current harvest status, data versions, content digests | `provenance/*.jsonl` ledgers, or run `uv run python scripts/check_health.py` | Volatile state, changes every pipeline run |
|
|
494
|
+
| What a config class guarantees | `docs/CICs/` — Class Intent Contracts | Code contracts |
|
|
495
|
+
| Why the system is designed this way | `docs/ADRs/` — Architecture Decision Records | Immutable decisions |
|
|
496
|
+
| Known technical risks and their status | `reports/technical_risk_register.md` | Living risk tracking |
|
|
497
|
+
|
|
498
|
+
**Rule of thumb:** if the information changes when *the upstream provider* changes something → catalog card. When *we* make a decision → ADR. When *we redeploy* → code config. When *the pipeline runs* → provenance ledger. When in doubt, the provenance ledger is the most authoritative source for anything operational.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
## Contributing
|
|
503
|
+
|
|
504
|
+
Contributions are welcome. Please consult the [VIEWS Platform contributing guidelines](https://github.com/views-platform) before submitting pull requests.
|
|
505
|
+
|
|
506
|
+
When adding new packages, follow the existing `datafactory_*` naming convention and ensure the new package:
|
|
507
|
+
- Has an `__init__.py` with `__all__` defined
|
|
508
|
+
- Is listed in `pyproject.toml` under `[tool.hatch.build.targets.wheel] packages`
|
|
509
|
+
- Imports only from `datafactory_provenance` (or provenance + priogrid for compilation nodes)
|
|
510
|
+
- Has corresponding tests in `tests/`
|
|
511
|
+
- Has an `ARCHITECTURE.md` describing purpose, boundaries, and invariants
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## License
|
|
516
|
+
|
|
517
|
+
This project is licensed under the MIT License — see [LICENSE](LICENSE). The license covers the software in this repository only; upstream data sources (UCDP, ACLED, GHS-POP, GHS-BUILT-S, V-Dem, SHDI, PRIO-GRID, GAUL, WDI) are subject to their respective providers' terms of use.
|
|
518
|
+
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
## Acknowledgements
|
|
522
|
+
|
|
523
|
+
Built as part of the [VIEWS](https://viewsforecasting.org/) (Violence & Impacts Early-Warning System) project, providing early warning for conflict to support humanitarian response and prevention.
|
|
524
|
+
|
|
525
|
+
Data sources:
|
|
526
|
+
- **[UCDP/GED](https://ucdp.uu.se/)** — Uppsala Conflict Data Program / Georeferenced Event Dataset
|
|
527
|
+
- **[PRIO-GRID](https://grid.prio.org/)** — Peace Research Institute Oslo global grid structure
|
|
528
|
+
- **[V-Dem](https://v-dem.net/)** — Varieties of Democracy Institute, University of Gothenburg
|