mloda-plugin-govdata 0.3.0__tar.gz → 0.5.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.
Files changed (72) hide show
  1. mloda_plugin_govdata-0.5.0/PKG-INFO +156 -0
  2. mloda_plugin_govdata-0.5.0/README.md +101 -0
  3. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/cache.py +10 -3
  4. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/period.py +11 -6
  5. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/reader.py +8 -2
  6. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/bundeswahlleiterin.py +4 -9
  7. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/core/discovery.py +8 -5
  8. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/core/locator.py +4 -1
  9. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/core/provenance.py +3 -3
  10. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/population.py +2 -0
  11. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/reader.py +30 -8
  12. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/uba.py +39 -14
  13. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/base.py +5 -11
  14. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/reference/sources.py +8 -9
  15. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/period.py +2 -3
  16. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/rebase.py +3 -4
  17. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/land_population_per_voter.py +9 -6
  18. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/recipes/model.py +4 -2
  19. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/recipes/write.py +13 -2
  20. mloda_plugin_govdata-0.5.0/mloda_plugin_govdata.egg-info/PKG-INFO +156 -0
  21. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata.egg-info/requires.txt +5 -3
  22. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/pyproject.toml +27 -5
  23. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/tests/test_capture_genesis_fixtures.py +48 -20
  24. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/tests/test_demo_definition.py +31 -5
  25. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/tests/test_land_join.py +44 -8
  26. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/tests/test_packaging.py +28 -1
  27. mloda_plugin_govdata-0.3.0/PKG-INFO +0 -203
  28. mloda_plugin_govdata-0.3.0/README.md +0 -163
  29. mloda_plugin_govdata-0.3.0/mloda_plugin_govdata.egg-info/PKG-INFO +0 -203
  30. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/LICENSE +0 -0
  31. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/NOTICE.md +0 -0
  32. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/__init__.py +0 -0
  33. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/conftest.py +0 -0
  34. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/__init__.py +0 -0
  35. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/__init__.py +0 -0
  36. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/__init__.py +0 -0
  37. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/api.py +0 -0
  38. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/auth.py +0 -0
  39. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/envelope.py +0 -0
  40. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/errors.py +0 -0
  41. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/hosts.py +0 -0
  42. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/parse.py +0 -0
  43. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/core/redact.py +0 -0
  44. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/destatis/locator.py +0 -0
  45. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/__init__.py +0 -0
  46. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/core/__init__.py +0 -0
  47. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/core/cache.py +0 -0
  48. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/core/client.py +0 -0
  49. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/core/parse.py +0 -0
  50. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/govdata/feature.py +0 -0
  51. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/__init__.py +0 -0
  52. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/__init__.py +0 -0
  53. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/crosswalk.py +0 -0
  54. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/keys.py +0 -0
  55. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/land_codes.py +0 -0
  56. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/nuts.py +0 -0
  57. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/rebase.py +0 -0
  58. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/reference/__init__.py +0 -0
  59. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/reference/bbsr.py +0 -0
  60. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/reference/download.py +0 -0
  61. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/reference/eurostat.py +0 -0
  62. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/core/reference/gv_isys.py +0 -0
  63. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/feature_groups/harmonization/nuts.py +0 -0
  64. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/recipes/__init__.py +0 -0
  65. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/recipes/credential_scan.py +0 -0
  66. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/recipes/frames.py +0 -0
  67. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata/recipes/load.py +0 -0
  68. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata.egg-info/SOURCES.txt +0 -0
  69. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata.egg-info/dependency_links.txt +0 -0
  70. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/mloda_plugin_govdata.egg-info/top_level.txt +0 -0
  71. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/setup.cfg +0 -0
  72. {mloda_plugin_govdata-0.3.0 → mloda_plugin_govdata-0.5.0}/tests/test_mloda_imports.py +0 -0
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.4
2
+ Name: mloda-plugin-govdata
3
+ Version: 0.5.0
4
+ Summary: mloda plugin providing connectors, harmonization and recipes for German government data (GovData.de CKAN API, Destatis GENESIS webservice).
5
+ Author-email: Tom Kaltofen <tomkaltofen@mloda.ai>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/mloda-ai/mloda-plugin-govdata
8
+ Project-URL: Repository, https://github.com/mloda-ai/mloda-plugin-govdata
9
+ Project-URL: Issues, https://github.com/mloda-ai/mloda-plugin-govdata/issues
10
+ Project-URL: Releases, https://github.com/mloda-ai/mloda-plugin-govdata/releases
11
+ Project-URL: Prototype Fund, https://www.prototypefund.de/projects/mloda-plugin-govdata
12
+ Keywords: mloda,mloda-plugin,open-data,govdata,destatis,genesis,regionalstatistik,official-statistics,german-government-data,ckan
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Programming Language :: Python :: 3.14
23
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Requires-Python: >=3.10
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ License-File: NOTICE.md
29
+ Requires-Dist: mloda<0.17.0,>=0.16.0
30
+ Requires-Dist: filelock>=3.12
31
+ Requires-Dist: httpx>=0.27
32
+ Requires-Dist: openpyxl>=3.1
33
+ Requires-Dist: pandas>=2.0
34
+ Requires-Dist: pyarrow>=17.0
35
+ Requires-Dist: pydantic>=2.0
36
+ Requires-Dist: tenacity>=8.0
37
+ Provides-Extra: demo
38
+ Requires-Dist: marimo>=0.14; extra == "demo"
39
+ Requires-Dist: altair>=5; extra == "demo"
40
+ Provides-Extra: dev
41
+ Requires-Dist: mloda-testing>=0.10.0; extra == "dev"
42
+ Requires-Dist: tox; extra == "dev"
43
+ Requires-Dist: tox-uv; extra == "dev"
44
+ Requires-Dist: uv>=0.11.15; extra == "dev"
45
+ Requires-Dist: pytest; extra == "dev"
46
+ Requires-Dist: ruff==0.17.0; extra == "dev"
47
+ Requires-Dist: mypy; extra == "dev"
48
+ Requires-Dist: bandit; extra == "dev"
49
+ Requires-Dist: hypothesis; extra == "dev"
50
+ Requires-Dist: packaging>=24.2; extra == "dev"
51
+ Requires-Dist: respx; extra == "dev"
52
+ Requires-Dist: pandas-stubs; extra == "dev"
53
+ Requires-Dist: tomli; python_version < "3.11" and extra == "dev"
54
+ Dynamic: license-file
55
+
56
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/LICENSE)
57
+ [![mloda](https://img.shields.io/badge/built%20with-mloda-blue.svg)](https://github.com/mloda-ai/mloda)
58
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
59
+ [![Tests](https://github.com/mloda-ai/mloda-plugin-govdata/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/mloda-ai/mloda-plugin-govdata/actions/workflows/test.yml?query=branch%3Amain)
60
+ [![Prototype Fund](https://img.shields.io/badge/Prototype%20Fund-Jahrgang%2002-f1c40f.svg)](https://prototypefund.de)
61
+
62
+ # mloda-plugin-govdata
63
+
64
+ German open government data as typed tables you can trust: found, downloaded, parsed, made comparable, and traceable to its source. A plugin for [mloda](https://github.com/mloda-ai/mloda): you name the columns, it does the rest.
65
+
66
+ ## Why
67
+
68
+ The data is open, but every team rewrites the same scripts:
69
+
70
+ - **German CSV.** Decimal commas, multi-row headers, and signs like `-` and `.` that mean different things.
71
+ - **Changing borders.** Göttingen and Osterode merged in 2016. The raw Destatis table shows three districts, and zeros for the years each one did not exist.
72
+ - **Lost provenance.** Which file, which license, which attribution: gone by the time the chart is done.
73
+
74
+ ## What's inside
75
+
76
+ | | |
77
+ | --- | --- |
78
+ | **Sources** | GovData.de, Destatis GENESIS (GENESIS-Online, Regionalstatistik), Bundeswahlleiterin election results, UBA air quality |
79
+ | **Harmonization** | district series on today's borders, NUTS codes for German region keys, typed years |
80
+ | **Recipes** | JSON files that pin the features, joins, source, license, and checksum of one result |
81
+
82
+ ## Install
83
+
84
+ ```bash
85
+ pip install mloda-plugin-govdata
86
+ ```
87
+
88
+ ## Quick start
89
+
90
+ No account needed for GovData:
91
+
92
+ ```python
93
+ from mloda.user import Feature, mloda
94
+ from mloda_plugin_govdata.feature_groups.govdata import StuttgartPopulationReader
95
+
96
+ slug = "einwohner-nach-altersgruppen-und-stadtbezirken"
97
+ result = mloda.run_all(
98
+ [Feature("Einwohner", options={StuttgartPopulationReader: slug})],
99
+ compute_frameworks=["PyArrowTable"],
100
+ )
101
+ ```
102
+
103
+ Destatis, with a free [GENESIS account](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/credentials.md):
104
+
105
+ ```python
106
+ from mloda_plugin_govdata.feature_groups.destatis import DestatisReader
107
+
108
+ result = mloda.run_all(
109
+ [Feature("value", options={DestatisReader: "12411-0010"})], # population by Land
110
+ compute_frameworks=["PyArrowTable"],
111
+ )
112
+ ```
113
+
114
+ Göttingen on today's borders, with `value__rebased` ([full example](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/harmonization.md#usage)):
115
+
116
+ ```
117
+ ~key ~year ~value ~flag ~sources
118
+ 03159 2013 322616.0 rebased [03152, 03156]
119
+ 03159 2015 329538.0 rebased [03152, 03156]
120
+ 03159 2016 327065.0 observed []
121
+ ```
122
+
123
+ ## Demo
124
+
125
+ A [marimo](https://marimo.io) notebook walks through every source, the Göttingen series, and a join of population and eligible voters for all 16 Länder:
126
+
127
+ ```bash
128
+ git clone https://github.com/mloda-ai/mloda-plugin-govdata.git
129
+ cd mloda-plugin-govdata
130
+ uv sync --all-extras
131
+ uv run marimo edit demos/govdata_demo.py
132
+ ```
133
+
134
+ The Destatis chapters skip themselves without GENESIS credentials. A second notebook, `demos/berlin_wahl_2026_demo.py`, reads four Berlin elections with one set of reader options.
135
+
136
+ ## Docs
137
+
138
+ - [Readers](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/readers.md): every source, dataset search, `peek`
139
+ - [Destatis options](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/destatis-options.md) and [credentials](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/credentials.md)
140
+ - [Harmonization](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/harmonization.md)
141
+ - [Recipes](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/recipes.md)
142
+ - [Architecture](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/architecture.md) and [adding a reader](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/adding-a-reader.md)
143
+
144
+ ## Status
145
+
146
+ Young but working, built during a Prototype Fund stage (June to November 2026). The API may still change; the [release notes](https://github.com/mloda-ai/mloda-plugin-govdata/releases) give a migration for every breaking change.
147
+
148
+ ## Funding
149
+
150
+ Funded by the German Federal Ministry of Research, Technology and Space (BMFTR) through the [Prototype Fund](https://prototypefund.de), supported by the [Open Knowledge Foundation Deutschland](https://okfn.de). Funding code: **16IS26S11**.
151
+
152
+ <p>
153
+ <img src="https://raw.githubusercontent.com/mloda-ai/mloda-plugin-govdata/main/logos/bmftr.png" alt="Funded by the Federal Ministry of Research, Technology and Space (BMFTR)" height="110">
154
+ &nbsp;&nbsp;&nbsp;
155
+ <img src="https://raw.githubusercontent.com/mloda-ai/mloda-plugin-govdata/main/logos/prototypefund.png" alt="Supported by the Prototype Fund" height="110">
156
+ </p>
@@ -0,0 +1,101 @@
1
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/LICENSE)
2
+ [![mloda](https://img.shields.io/badge/built%20with-mloda-blue.svg)](https://github.com/mloda-ai/mloda)
3
+ [![Python](https://img.shields.io/badge/python-3.10%2B-blue.svg)](https://www.python.org/)
4
+ [![Tests](https://github.com/mloda-ai/mloda-plugin-govdata/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/mloda-ai/mloda-plugin-govdata/actions/workflows/test.yml?query=branch%3Amain)
5
+ [![Prototype Fund](https://img.shields.io/badge/Prototype%20Fund-Jahrgang%2002-f1c40f.svg)](https://prototypefund.de)
6
+
7
+ # mloda-plugin-govdata
8
+
9
+ German open government data as typed tables you can trust: found, downloaded, parsed, made comparable, and traceable to its source. A plugin for [mloda](https://github.com/mloda-ai/mloda): you name the columns, it does the rest.
10
+
11
+ ## Why
12
+
13
+ The data is open, but every team rewrites the same scripts:
14
+
15
+ - **German CSV.** Decimal commas, multi-row headers, and signs like `-` and `.` that mean different things.
16
+ - **Changing borders.** Göttingen and Osterode merged in 2016. The raw Destatis table shows three districts, and zeros for the years each one did not exist.
17
+ - **Lost provenance.** Which file, which license, which attribution: gone by the time the chart is done.
18
+
19
+ ## What's inside
20
+
21
+ | | |
22
+ | --- | --- |
23
+ | **Sources** | GovData.de, Destatis GENESIS (GENESIS-Online, Regionalstatistik), Bundeswahlleiterin election results, UBA air quality |
24
+ | **Harmonization** | district series on today's borders, NUTS codes for German region keys, typed years |
25
+ | **Recipes** | JSON files that pin the features, joins, source, license, and checksum of one result |
26
+
27
+ ## Install
28
+
29
+ ```bash
30
+ pip install mloda-plugin-govdata
31
+ ```
32
+
33
+ ## Quick start
34
+
35
+ No account needed for GovData:
36
+
37
+ ```python
38
+ from mloda.user import Feature, mloda
39
+ from mloda_plugin_govdata.feature_groups.govdata import StuttgartPopulationReader
40
+
41
+ slug = "einwohner-nach-altersgruppen-und-stadtbezirken"
42
+ result = mloda.run_all(
43
+ [Feature("Einwohner", options={StuttgartPopulationReader: slug})],
44
+ compute_frameworks=["PyArrowTable"],
45
+ )
46
+ ```
47
+
48
+ Destatis, with a free [GENESIS account](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/credentials.md):
49
+
50
+ ```python
51
+ from mloda_plugin_govdata.feature_groups.destatis import DestatisReader
52
+
53
+ result = mloda.run_all(
54
+ [Feature("value", options={DestatisReader: "12411-0010"})], # population by Land
55
+ compute_frameworks=["PyArrowTable"],
56
+ )
57
+ ```
58
+
59
+ Göttingen on today's borders, with `value__rebased` ([full example](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/harmonization.md#usage)):
60
+
61
+ ```
62
+ ~key ~year ~value ~flag ~sources
63
+ 03159 2013 322616.0 rebased [03152, 03156]
64
+ 03159 2015 329538.0 rebased [03152, 03156]
65
+ 03159 2016 327065.0 observed []
66
+ ```
67
+
68
+ ## Demo
69
+
70
+ A [marimo](https://marimo.io) notebook walks through every source, the Göttingen series, and a join of population and eligible voters for all 16 Länder:
71
+
72
+ ```bash
73
+ git clone https://github.com/mloda-ai/mloda-plugin-govdata.git
74
+ cd mloda-plugin-govdata
75
+ uv sync --all-extras
76
+ uv run marimo edit demos/govdata_demo.py
77
+ ```
78
+
79
+ The Destatis chapters skip themselves without GENESIS credentials. A second notebook, `demos/berlin_wahl_2026_demo.py`, reads four Berlin elections with one set of reader options.
80
+
81
+ ## Docs
82
+
83
+ - [Readers](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/readers.md): every source, dataset search, `peek`
84
+ - [Destatis options](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/destatis-options.md) and [credentials](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/credentials.md)
85
+ - [Harmonization](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/harmonization.md)
86
+ - [Recipes](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/recipes.md)
87
+ - [Architecture](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/architecture.md) and [adding a reader](https://github.com/mloda-ai/mloda-plugin-govdata/blob/main/docs/adding-a-reader.md)
88
+
89
+ ## Status
90
+
91
+ Young but working, built during a Prototype Fund stage (June to November 2026). The API may still change; the [release notes](https://github.com/mloda-ai/mloda-plugin-govdata/releases) give a migration for every breaking change.
92
+
93
+ ## Funding
94
+
95
+ Funded by the German Federal Ministry of Research, Technology and Space (BMFTR) through the [Prototype Fund](https://prototypefund.de), supported by the [Open Knowledge Foundation Deutschland](https://okfn.de). Funding code: **16IS26S11**.
96
+
97
+ <p>
98
+ <img src="https://raw.githubusercontent.com/mloda-ai/mloda-plugin-govdata/main/logos/bmftr.png" alt="Funded by the Federal Ministry of Research, Technology and Space (BMFTR)" height="110">
99
+ &nbsp;&nbsp;&nbsp;
100
+ <img src="https://raw.githubusercontent.com/mloda-ai/mloda-plugin-govdata/main/logos/prototypefund.png" alt="Supported by the Prototype Fund" height="110">
101
+ </p>
@@ -36,19 +36,26 @@ _SHA256 = re.compile(r"[0-9a-f]{64}")
36
36
 
37
37
  # Comma-separated selections the server treats as sets: sorted for the key and on the wire.
38
38
  SELECTION_FIELDS: frozenset[str] = frozenset({"regionalkey", *CLASSIFYING_KEYS})
39
+ # Numeric fields; anywhere else an int would drop a code's leading zeros.
40
+ _INT_FIELDS: frozenset[str] = frozenset({"startyear", "endyear", "timeslices"})
39
41
 
40
42
 
41
43
  def _wire_scalar(name: str, value: object) -> str:
42
- """One value as it travels: strings stripped, ints as digits; bools refused."""
44
+ """One value as it travels: strings stripped, ints as digits (``_INT_FIELDS`` only); bools refused."""
43
45
  if isinstance(value, bool):
44
46
  # The spec spells booleans per field ("true"/"false" for compress, "on"/"off" for quality).
45
47
  raise TypeError(f"parameter {name!r}: pass the wire string for booleans, not a bool")
46
48
  if isinstance(value, int):
47
- return str(value)
49
+ if name in _INT_FIELDS:
50
+ return str(value)
51
+ raise TypeError(f"parameter {name!r} must be a str: an int loses a code's leading zeros")
48
52
  if isinstance(value, str):
49
53
  return value.strip()
50
54
  # Named by field only: a value could be a secret pasted into the wrong place.
51
- raise TypeError(f"parameter {name!r} must be a str, int, or a flat sequence of those, got {type(value).__name__}")
55
+ raise TypeError(
56
+ f"parameter {name!r} must be a str (an int for {', '.join(sorted(_INT_FIELDS))}) "
57
+ f"or a flat sequence of those, got {type(value).__name__}"
58
+ )
52
59
 
53
60
 
54
61
  def canonical_parameters(endpoint: str, parameters: Mapping[str, object]) -> dict[str, str]:
@@ -4,7 +4,8 @@ GENESIS annual tables carry two labels for the same annual granularity: JAHR
4
4
  (a plain year, ``"2015"``) and STAG (a 31 Dec reference date, ``"2015-12-31"``
5
5
  or ``"31.12.2015"``). Both normalize to the same annual :class:`Period`; only
6
6
  the year matters, not which label produced it. kerg has no time column, the
7
- election date comes from the locator or recipe (:func:`from_snapshot`).
7
+ election date comes from the locator or recipe (:func:`from_snapshot`); the
8
+ Destatis Stichtag a snapshot joins to is :func:`stichtag_period`.
8
9
  Quarter and month parsing are not built:
9
10
  :class:`Frequency` keeps all three values for forward compatibility, but only
10
11
  ``year`` has a working parser.
@@ -85,11 +86,9 @@ def _annual_stag(label: str, *, year: int, month: int, day: int) -> Period:
85
86
  def from_snapshot(snapshot: date, freq: Frequency = Frequency.YEAR) -> Period:
86
87
  """Builds a :class:`Period` from a point-in-time snapshot (e.g. an election date).
87
88
 
88
- Floors to the calendar year containing ``snapshot``. This is not the
89
- snapshot-to-annual join policy (which Destatis reference year a snapshot
90
- joins to for cross-source analysis); that decision is deferred to the
91
- join plumbing. Only ``Frequency.YEAR`` is implemented; quarter and
92
- month raise ``NotImplementedError``.
89
+ Floors to the calendar year containing ``snapshot``: the snapshot's own year,
90
+ not the Destatis year it joins to (that is :func:`stichtag_period`). Only
91
+ ``Frequency.YEAR`` is implemented; quarter and month raise ``NotImplementedError``.
93
92
  """
94
93
  freq = Frequency(freq)
95
94
  if freq is not Frequency.YEAR:
@@ -97,6 +96,12 @@ def from_snapshot(snapshot: date, freq: Frequency = Frequency.YEAR) -> Period:
97
96
  return Period(date(snapshot.year, 1, 1), freq)
98
97
 
99
98
 
99
+ def stichtag_period(snapshot: date) -> Period:
100
+ """The annual period of the last 31 Dec Stichtag on or before ``snapshot`` (the join year for an election)."""
101
+ year = snapshot.year if (snapshot.month, snapshot.day) == (12, 31) else snapshot.year - 1
102
+ return Period(date(year, 1, 1), Frequency.YEAR)
103
+
104
+
100
105
  def assert_same_frequency(left: Period, right: Period) -> None:
101
106
  """Raises ``ValueError`` naming both frequencies on a mismatch. No implicit aggregation."""
102
107
  if left.freq is not right.freq:
@@ -11,12 +11,13 @@ from __future__ import annotations
11
11
 
12
12
  import functools
13
13
  from pathlib import Path
14
- from typing import Any
14
+ from typing import Any, ClassVar
15
15
 
16
16
  import pyarrow as pa
17
17
  from mloda.provider import CHAIN_SEPARATOR, COLUMN_SEPARATOR
18
18
  from mloda.user import Options
19
19
 
20
+ from ..govdata.core.discovery import DL_DE_BY_2_0
20
21
  from ..govdata.core.provenance import FetchedPayload, Provenance
21
22
  from ..govdata.reader import BaseGovDataReader
22
23
  from .core.api import GenesisClient, fetch_tablefile
@@ -30,6 +31,9 @@ from .locator import DestatisLocator
30
31
  class DestatisReader(BaseGovDataReader[DestatisLocator]):
31
32
  """Reads one GENESIS table selection into a typed Arrow table, ffcsv parsed."""
32
33
 
34
+ # The reader resolves only the known GENESIS hosts, and both publish under DL-DE-BY-2.0.
35
+ LICENSE: ClassVar[str | None] = DL_DE_BY_2_0
36
+
33
37
  @classmethod
34
38
  def suffix(cls) -> tuple[str, ...]:
35
39
  return (".zip",)
@@ -58,7 +62,9 @@ class DestatisReader(BaseGovDataReader[DestatisLocator]):
58
62
  with GenesisClient(host, credentials=explicit, lock_dir=cls.cache_dir) as client:
59
63
  fetch = functools.partial(fetch_tablefile, client)
60
64
  cached = cache.get_or_fetch(host, "data/tablefile", fields, fetch)
61
- provenance = Provenance(source="genesis", url=host.url("data/tablefile"), parameters=cached.parameters)
65
+ provenance = Provenance(
66
+ source="genesis", url=host.url("data/tablefile"), parameters=cached.parameters, license=cls.LICENSE
67
+ )
62
68
  return FetchedPayload(
63
69
  path=cached.path, sha256=cached.sha256, retrieved_at=cached.retrieved_at, provenance=provenance
64
70
  )
@@ -49,37 +49,32 @@ class BundeswahlleiterinReader(BaseGovDataReader[GovDataLocator]):
49
49
  "Preamble lines to skip before the header block.",
50
50
  default=5,
51
51
  strict_validation=True,
52
+ scalar_only=True,
52
53
  element_validator=_is_non_negative_int,
53
54
  ),
54
55
  OPTION_WAHL_HEADER_ROWS: PropertySpec(
55
56
  "Merged header rows flattened into column names.",
56
57
  default=3,
57
58
  strict_validation=True,
59
+ scalar_only=True,
58
60
  element_validator=is_positive_int,
59
61
  ),
60
62
  OPTION_WAHL_LABEL_COLUMNS: PropertySpec(
61
63
  "Leading columns typed as strings, not value_type.",
62
64
  default=4,
63
65
  strict_validation=True,
66
+ scalar_only=True,
64
67
  element_validator=_is_non_negative_int,
65
68
  ),
66
69
  OPTION_WAHL_VALUE_TYPE: PropertySpec(
67
70
  "ColumnType of the non-label columns.",
68
71
  default=ColumnType.INTEGER,
69
72
  strict_validation=True,
73
+ scalar_only=True,
70
74
  allowed_values=tuple(ColumnType),
71
75
  ),
72
76
  }
73
77
 
74
- @classmethod
75
- def match_subclass_data_access(cls, data_access: Any, feature_names: list[str], options: Any) -> Any:
76
- locator = super().match_subclass_data_access(data_access, feature_names, options)
77
- if locator is None:
78
- return None
79
- for key in cls.READER_OPTIONS:
80
- cls._scalar_reader_option(key, options)
81
- return locator
82
-
83
78
  @classmethod
84
79
  def _parse(cls, path: Path, locator: GovDataLocator, *, options: Options | None = None) -> pa.Table:
85
80
  return parse_multi_header_csv(
@@ -12,13 +12,16 @@ from pydantic import BaseModel, ConfigDict
12
12
  from .client import request_with_retry
13
13
  from .locator import DEFAULT_CKAN_BASE, GovDataLocator
14
14
 
15
- # dcat-ap.de license URIs observed across GovData distributions -> short labels.
15
+ CC_BY_4_0 = "CC-BY-4.0"
16
+ DL_DE_BY_2_0 = "DL-DE-BY-2.0"
17
+
18
+ # dcat-ap.de license URIs observed across GovData distributions -> SPDX ids, LicenseRef- where SPDX has none.
16
19
  LICENSE_LABELS: dict[str, str] = {
17
- "http://dcat-ap.de/def/licenses/cc-by/4.0": "CC-BY-4.0",
18
- "http://dcat-ap.de/def/licenses/dl-by-de/2.0": "DL-DE-BY-2.0",
19
- "http://dcat-ap.de/def/licenses/dl-zero-de/2.0": "DL-DE-Zero-2.0",
20
+ "http://dcat-ap.de/def/licenses/cc-by/4.0": CC_BY_4_0,
21
+ "http://dcat-ap.de/def/licenses/dl-by-de/2.0": DL_DE_BY_2_0,
22
+ "http://dcat-ap.de/def/licenses/dl-zero-de/2.0": "DL-DE-ZERO-2.0",
20
23
  "http://dcat-ap.de/def/licenses/cc-zero": "CC0-1.0",
21
- "http://dcat-ap.de/def/licenses/geonutz/20130319": "GeoNutzV",
24
+ "http://dcat-ap.de/def/licenses/geonutz/20130319": "LicenseRef-GeoNutzV",
22
25
  }
23
26
 
24
27
 
@@ -12,7 +12,10 @@ _L = TypeVar("_L", bound="Locator")
12
12
 
13
13
  @runtime_checkable
14
14
  class Locator(Protocol):
15
- """What a reader needs from its locator type: coercion from an option value and a label for messages."""
15
+ """What a reader needs from its locator type: coercion from an option value and a label.
16
+
17
+ The label names the dataset in messages and in lineage and audit records, so it never carries a credential.
18
+ """
16
19
 
17
20
  # PYI019 wants `Self`, which is 3.11+; the package floor is 3.10.
18
21
  @classmethod
@@ -21,12 +21,12 @@ class Provenance:
21
21
  dataset: Dataset | None = None
22
22
 
23
23
  @classmethod
24
- def from_distribution(cls, distribution: ResolvedDistribution) -> Provenance:
25
- """``ckan`` when discovery ran, ``url`` for a direct distribution."""
24
+ def from_distribution(cls, distribution: ResolvedDistribution, default_license: str | None = None) -> Provenance:
25
+ """``ckan`` when discovery ran, ``url`` for a direct distribution; ``default_license`` when it reports none."""
26
26
  return cls(
27
27
  source="ckan" if distribution.dataset is not None else "url",
28
28
  url=distribution.url,
29
- license=distribution.license,
29
+ license=distribution.license or default_license,
30
30
  dataset=distribution.dataset,
31
31
  )
32
32
 
@@ -4,6 +4,7 @@ from __future__ import annotations
4
4
 
5
5
  from typing import ClassVar
6
6
 
7
+ from .core.discovery import CC_BY_4_0
7
8
  from .core.parse import ColumnType
8
9
  from .reader import GovDataReader
9
10
 
@@ -20,3 +21,4 @@ class StuttgartPopulationReader(GovDataReader):
20
21
  """Residents by age group and city district, with typed columns."""
21
22
 
22
23
  schema: ClassVar[dict[str, ColumnType] | None] = POPULATION_SCHEMA
24
+ LICENSE: ClassVar[str | None] = CC_BY_4_0
@@ -9,12 +9,13 @@ the cache, parse it into a typed Arrow table. One module per data source impleme
9
9
  from __future__ import annotations
10
10
 
11
11
  import difflib
12
+ from collections.abc import Mapping
12
13
  from pathlib import Path
13
14
  from typing import Any, ClassVar, Generic, TypeVar, cast
14
15
 
15
16
  import pyarrow as pa
16
17
  from mloda.provider import FeatureSet
17
- from mloda.user import Options
18
+ from mloda.user import DataType, Options
18
19
  from mloda.user.pyarrow import PyArrowTable # noqa: F401
19
20
  from mloda_plugins.feature_group.input_data.read_file import ReadFile
20
21
 
@@ -51,6 +52,8 @@ class BaseGovDataReader(ReadFile, Generic[LocatorT]):
51
52
 
52
53
  # Persistent, content-addressed cache location (override per environment).
53
54
  cache_dir: ClassVar[str] = str(DEFAULT_CACHE_DIR)
55
+ # The one license every payload of this reader carries, as normalize_license labels it; None when it varies.
56
+ LICENSE: ClassVar[str | None] = None
54
57
 
55
58
  @classmethod
56
59
  def suffix(cls) -> tuple[str, ...]:
@@ -97,12 +100,26 @@ class BaseGovDataReader(ReadFile, Generic[LocatorT]):
97
100
  return {field.name: str(field.type) for field in table.schema}
98
101
 
99
102
  @classmethod
100
- def _scalar_reader_option(cls, key: str, options: Any) -> Any:
101
- """Reject a collection value, since strict_validation only checks list elements individually."""
102
- value = cls.reader_option(key, options)
103
- if isinstance(value, (list, tuple, set, frozenset)):
104
- raise ValueError(f"{cls.__name__} option '{key}' takes a single value, got {value!r}.") # noqa: TRY004
105
- return value
103
+ def describe_columns(cls, data_access: Any) -> dict[str, DataType | None]:
104
+ """``peek`` as mloda's column discovery (lineage extenders call it); downloads through the cache too."""
105
+ table = cls._read_table(cls._coerce_locator(data_access))
106
+ return {field.name: DataType.from_arrow_type_safe(field.type) for field in table.schema}
107
+
108
+ @classmethod
109
+ def data_access_identity(cls, data_access: Any) -> str:
110
+ """The dataset name in lineage and audit records: the locator label, a URL cut to scheme, host and path.
111
+
112
+ mloda's default names every locator by its type alone. The selection (years, keys, a URL query) is left out.
113
+ """
114
+ if not isinstance(data_access, cls.locator_type()):
115
+ return super().data_access_identity(data_access)
116
+ label = data_access.describe()
117
+ return super().data_access_identity(label) if label.startswith(("http://", "https://")) else label
118
+
119
+ @classmethod
120
+ def declared_attributes(cls, features: FeatureSet | None) -> Mapping[str, str | int | float | bool]:
121
+ """``license`` for extenders and ``required_declarations``, the same at plan and load time."""
122
+ return {"license": cls.LICENSE} if cls.LICENSE else {}
106
123
 
107
124
  @classmethod
108
125
  def _coerce_locator(cls, data_access: Any) -> LocatorT:
@@ -123,12 +140,17 @@ class BaseGovDataReader(ReadFile, Generic[LocatorT]):
123
140
  raise NotImplementedError(f"{cls.__name__} must implement _fetch for {type(locator).__name__}")
124
141
  with build_client() as client:
125
142
  distribution = resolve_distribution(locator, client)
143
+ if cls.LICENSE and distribution.license and distribution.license != cls.LICENSE:
144
+ raise ValueError(
145
+ f"{cls.__name__} declares license {cls.LICENSE!r}, but {locator.describe()!r} is published "
146
+ f"under {distribution.license!r}; read it with a reader that declares no license."
147
+ )
126
148
  cached = DownloadCache(cls.cache_dir, client=client).get_or_download(distribution.url)
127
149
  return FetchedPayload(
128
150
  path=cached.path,
129
151
  sha256=cached.sha256,
130
152
  retrieved_at=cached.retrieved_at,
131
- provenance=Provenance.from_distribution(distribution),
153
+ provenance=Provenance.from_distribution(distribution, cls.LICENSE),
132
154
  )
133
155
 
134
156
  @classmethod