ies-ingest 0.1.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.
@@ -0,0 +1,33 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ verify:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ matrix:
17
+ python-version: ["3.11", "3.12"]
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ - name: Install
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install -e ".[dev]"
28
+ - name: Lint
29
+ run: ruff check ies_ingest tests
30
+ - name: Test
31
+ run: pytest -q
32
+ - name: Demo
33
+ run: python -m ies_ingest.examples.one_state
@@ -0,0 +1,89 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ contents: write # create GitHub release
10
+ id-token: write # OIDC token for PyPI trusted publishing
11
+
12
+ jobs:
13
+ build:
14
+ name: Build distribution
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: "3.11"
23
+
24
+ - name: Install hatch
25
+ run: pip install hatch
26
+
27
+ - name: Build wheel + sdist
28
+ run: hatch build
29
+
30
+ - name: Upload build artefacts
31
+ uses: actions/upload-artifact@v4
32
+ with:
33
+ name: dist
34
+ path: dist/
35
+
36
+ publish-testpypi:
37
+ name: Publish to TestPyPI
38
+ needs: build
39
+ runs-on: ubuntu-latest
40
+ environment:
41
+ name: testpypi
42
+ url: https://test.pypi.org/p/ies-ingest
43
+ steps:
44
+ - name: Download dist
45
+ uses: actions/download-artifact@v4
46
+ with:
47
+ name: dist
48
+ path: dist/
49
+
50
+ - name: Publish to TestPyPI
51
+ uses: pypa/gh-action-pypi-publish@release/v1
52
+ with:
53
+ repository-url: https://test.pypi.org/legacy/
54
+
55
+ publish-pypi:
56
+ name: Publish to PyPI
57
+ needs: publish-testpypi
58
+ runs-on: ubuntu-latest
59
+ environment:
60
+ name: pypi
61
+ url: https://pypi.org/p/ies-ingest
62
+ steps:
63
+ - name: Download dist
64
+ uses: actions/download-artifact@v4
65
+ with:
66
+ name: dist
67
+ path: dist/
68
+
69
+ - name: Publish to PyPI
70
+ uses: pypa/gh-action-pypi-publish@release/v1
71
+
72
+ github-release:
73
+ name: Create GitHub Release
74
+ needs: publish-pypi
75
+ runs-on: ubuntu-latest
76
+ steps:
77
+ - uses: actions/checkout@v4
78
+
79
+ - name: Download dist
80
+ uses: actions/download-artifact@v4
81
+ with:
82
+ name: dist
83
+ path: dist/
84
+
85
+ - name: Create GitHub Release
86
+ uses: softprops/action-gh-release@v2
87
+ with:
88
+ body_path: CHANGELOG.md
89
+ files: dist/*
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .venv/
5
+ .pytest_cache/
6
+ .ruff_cache/
7
+ dist/
8
+ build/
9
+ .coverage
10
+ htmlcov/
11
+ .DS_Store
12
+ *.swp
13
+ .idea/
14
+ .vscode/
15
+ .venv/
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to `ies-ingest` are documented here.
4
+ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
+ Versioning follows [SemVer](https://semver.org/).
6
+
7
+ ## [0.1.0] — 2026-05-07
8
+
9
+ Initial public release. Apache 2.0 donation to the India Energy Stack (IES) Accelerator track.
10
+
11
+ ### Added
12
+
13
+ - `StateDemandRow` — Pydantic v2 contract for a single state-hour demand observation, with `source_kind` provenance classification (`observed` / `modelled` / `scheduled` / `missing`).
14
+ - `canonical_state_key()` — normalises free-text state names to a canonical lowercase slug for all 28 states + UTs covered by IES v0.4.
15
+ - `atlas_now()` / `format_atlas_hour()` / `to_utc()` — IST-aware clock utilities; produces the canonical `YYYY-MM-DDTHH:MM:SS+05:30` atlas-hour string.
16
+ - `finalize_state_demand_row()` — applies the full contract: classifies provenance, demotes observed-but-null rows to `missing`, and refuses to serve fake observations.
17
+ - `atlas_envelope()` — wraps a finalised row dict in the IES-shaped source-health envelope (`atlas_hour`, `source_health`, `data`).
18
+ - `Source` / `build_default_registry()` / `run_pull_with_timeout()` — pluggable source registry with per-source timeout discipline.
19
+ - `Health` / `compute_health()` — rolling source-health aggregation (`green` / `yellow` / `red`).
20
+ - `examples.one_state` — runnable end-to-end demo (`python -m ies_ingest.examples.one_state`).
21
+ - 60 unit tests with 88 % line coverage.
22
+ - `Makefile` with `make verify` (lint → test → demo in one command).
23
+ - CI on GitHub Actions: matrix Python 3.11 / 3.12.
24
+
25
+ ### Notes
26
+
27
+ - Produced against IES Architecture v0.4 (Ministry of Power, 27 Mar 2026).
28
+ - This package is **IES-shaped** — it is not certified IES-compliant.
29
+ - `sources.py` contains the pluggable pull framework; adapters for live SLDC/NLDC sources are intentionally out of scope for 0.1.0 (add your own `Source` subclass).
30
+
31
+ [0.1.0]: https://github.com/India-Energy-Atlas/ies-ingest/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ # Code of Conduct
2
+
3
+ This project adopts the [Contributor Covenant v2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/) in full.
4
+
5
+ ## TL;DR
6
+
7
+ - Be kind. Disagreements over technical decisions are fine; personal attacks are not.
8
+ - Assume good faith. Most disagreements are misunderstandings.
9
+ - This community welcomes contributors regardless of background, identity, or experience level.
10
+
11
+ ## Reporting
12
+
13
+ If you experience or witness behaviour that violates the Covenant, please email `conduct@energymap.in`. Reports are kept confidential. Maintainers will respond within 7 days.
14
+
15
+ ## Scope
16
+
17
+ The Code of Conduct applies in all project spaces: GitHub issues, PRs, discussions, project social channels, and any in-person or virtual events organised under this project's name.
18
+
19
+ ## Enforcement
20
+
21
+ Maintainers may, at their discretion, edit or delete comments, commits, code, issues, and other contributions that violate the Code, and may temporarily or permanently ban contributors whose behaviour is deemed inappropriate, threatening, offensive, or harmful.
@@ -0,0 +1,46 @@
1
+ # Contributing to ies-ingest
2
+
3
+ Thank you for considering a contribution. This is a small, focused codebase — short PRs that do one thing well are welcome.
4
+
5
+ ## Setup
6
+
7
+ ```bash
8
+ git clone https://github.com/india-energy-atlas/ies-ingest
9
+ cd ies-ingest
10
+ python -m venv .venv && source .venv/bin/activate
11
+ pip install -e ".[dev]"
12
+ make verify
13
+ ```
14
+
15
+ Python 3.11+ required.
16
+
17
+ ## Workflow
18
+
19
+ 1. Open an issue first for non-trivial changes — keeps everyone aligned on scope.
20
+ 2. Branch from `main`. Use a descriptive branch name (`add-meghalaya-variant`, `fix-clock-dst-edge`).
21
+ 3. One logical change per PR. Conventional Commits in messages (`fix(contract): reject negative demand on observed rows`).
22
+ 4. Tests required for new behaviour. Bug fixes that *don't* add a regression test will be asked to.
23
+ 5. `make verify` must pass locally before push. CI will run the same checks.
24
+ 6. PR description names *what* changed and *why*. The "why" matters more.
25
+
26
+ ## What we accept
27
+
28
+ - New state-name variants observed in real SLDC feeds (with the source URL).
29
+ - Bug fixes with a test that fails on `main` and passes on the PR.
30
+ - Performance improvements with a before/after benchmark in the description.
31
+ - New `Source` adapters that respect the existing contract (no DB dependency at the contract layer).
32
+ - Documentation improvements — typos, clearer examples, added v0.4 page references.
33
+
34
+ ## What we are cautious about
35
+
36
+ - New runtime dependencies. Each one is a maintenance tax forever; argue the case in the issue.
37
+ - Changes that couple this package to a specific database or message bus. The contract layer is DB-agnostic by design.
38
+ - Anything that claims IES certification. We never make that claim — see the README's "Positioning" section.
39
+
40
+ ## Reporting security issues
41
+
42
+ Please do **not** open public issues for security vulnerabilities. Email `security@energymap.in` instead. We aim to acknowledge within 48 hours.
43
+
44
+ ## Code of conduct
45
+
46
+ By participating, you agree to abide by [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for describing the origin of the Work and
141
+ reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Support. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or support.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 India Energy Atlas (energymap.in)
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
200
+ implied. See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,23 @@
1
+ .PHONY: install verify test lint demo clean
2
+
3
+ install:
4
+ pip install -e ".[dev]"
5
+
6
+ verify: lint test demo
7
+ @echo ""
8
+ @echo "verify ok — package imports, tests pass, demo runs."
9
+
10
+ test:
11
+ pytest -q
12
+
13
+ lint:
14
+ ruff check ies_ingest tests
15
+
16
+ demo:
17
+ @echo ""
18
+ @echo "=== ies-ingest demo: end-to-end one-state ingestion ==="
19
+ @python -m ies_ingest.examples.one_state
20
+
21
+ clean:
22
+ rm -rf .pytest_cache __pycache__ ies_ingest/__pycache__ tests/__pycache__ .ruff_cache
23
+ rm -rf build dist *.egg-info
@@ -0,0 +1,21 @@
1
+ ies-ingest
2
+ Copyright 2026 India Energy Atlas (energymap.in)
3
+
4
+ This product includes software developed at India Energy Atlas
5
+ (https://energymap.in/).
6
+
7
+ Original code extracted from the energymap.in production stack
8
+ (https://github.com/sayonsom/espresso-india-transmission-map),
9
+ specifically:
10
+
11
+ - services/tools-api/app/freshness/ (atlas freshness DAG, envelope, health)
12
+ - services/tools-api/app/coverage/ (3-tier gap fill — referenced, not yet ported)
13
+ - src/transmission_map/state_demand_contract.py
14
+ - src/transmission_map/canonical_states.py
15
+
16
+ Donation framing: this repository is offered into the India Energy Stack
17
+ (IES) Accelerator track per IES Architecture v0.4 §"Adoption Strategy"
18
+ (Ministry of Power, 27 Mar 2026). It is "IES-shaped" — produced against
19
+ v0.4 — but is NOT certified IES-compliant. The India Energy Stack
20
+ programme is owned by the Ministry of Power; this contribution does not
21
+ speak for IES.
@@ -0,0 +1,177 @@
1
+ Metadata-Version: 2.4
2
+ Name: ies-ingest
3
+ Version: 0.1.0
4
+ Summary: Orchestration and contract layer for IES-shaped state-demand ingestion. Apache 2.0 donation to the IES Accelerator track.
5
+ Project-URL: Homepage, https://energymap.in
6
+ Project-URL: Repository, https://github.com/india-energy-atlas/ies-ingest
7
+ Project-URL: Issues, https://github.com/india-energy-atlas/ies-ingest/issues
8
+ Author-email: India Energy Atlas <hello@energymap.in>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ License-File: NOTICE
12
+ Keywords: energy,freshness,grid,ies,india,india-energy-stack,observability,sldc
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: pydantic>=2.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
26
+ Requires-Dist: pytest>=7.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.1; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # ies-ingest
31
+
32
+ > **A donation into the India Energy Stack (IES) Accelerator track.** Apache 2.0. Maintained by [India Energy Atlas](https://energymap.in) (energymap.in). Produced against IES Architecture v0.4 (Ministry of Power, 27 Mar 2026). *Not* certified IES-compliant — see "Positioning" below.
33
+
34
+ `ies-ingest` is the **orchestration and contract layer** that sits between raw State Load Dispatch Centre (SLDC) feeds and an IES-shaped consumer API. It is the same code that powers [energymap.in](https://energymap.in)'s public state-demand surface, extracted into a small, dependency-light Python package so other IES participants — pilot DISCOMs, SERCs, regulators, research bodies — can adopt it without inheriting the rest of energymap.
35
+
36
+ It does NOT include the per-state SLDC scrapers themselves; those live in a sibling collector that will be donated as a separate repo. See "Scope, honestly" below.
37
+
38
+ ---
39
+
40
+ ## Why this exists
41
+
42
+ IES Architecture v0.4 §"Adoption Strategy" calls for *"sandbox environments, tools, reference solutions, and other ecosystem enablers"* (p. 7). Pilots in Delhi, Gujarat, and Maharashtra need exactly this plumbing today. Rather than wait for an Accelerator-curated solution, we are donating the orchestration layer we already run in production.
43
+
44
+ The strategic frame, in plain English: REC Limited (the IES nodal authority) does not need another vendor selling APIs. It needs working public-goods code that pilots can pick up and run. This repository is that code.
45
+
46
+ ---
47
+
48
+ ## What's in the box
49
+
50
+ ```
51
+ ies_ingest/
52
+ ├── contract.py # StateDemandRow, source_kind enum, finaliser
53
+ ├── canonical_states.py # Collapse 33+ state-name variants to one canonical key
54
+ ├── clock.py # IST-aligned canonical hour ("atlas_now")
55
+ ├── envelope.py # Lightweight {atlas_hour, source_health, data} wrapper
56
+ ├── health.py # Red / yellow / green from rolling status window
57
+ ├── sources.py # Source registry — pull / check / timeout per metric
58
+ └── examples/
59
+ └── one_state.py # End-to-end Delhi demo — fake SLDC row → contract → envelope
60
+ ```
61
+
62
+ | Module | Lines | What it does | Why it matters for IES |
63
+ |---|---:|---|---|
64
+ | `contract.py` | ~200 | Public contract for a state-demand row. Distinguishes `observed` from `modeled` / `synthesized` / `derived` / `missing`. Refuses to serve null observed values. | IES Annexure 3 §"Provenance" — every reading must declare its provenance class. |
65
+ | `canonical_states.py` | ~130 | Maps every known SLDC variant ("J&K", "Jammu and Kashmir", "jammu-kashmir") to one canonical key. | Federation requires deterministic identifiers. This is the cheapest possible step toward IES Identity & Addressability (v0.4 §15). |
66
+ | `envelope.py` + `clock.py` | ~125 | Wraps every API response with an IST `atlas_hour` stamp + source-health label. | Conformance artefact A (trace context) + D (boundary metrics) per cheat-sheet §5c. |
67
+ | `health.py` | ~35 | Rolling 3-window health: 0/3 fail = green, 1/3 = yellow, 2/3 = red. | Programme Observability — Friction surface (v0.4 pp. 26–28). |
68
+ | `sources.py` | ~110 | Registry of `Source(metric, pull, check, timeout, observed_only)`. Async runner with timeout. | IES Programme Observability — Adoption surface. |
69
+
70
+ Total surface: **~600 lines of Python, no Postgres or Prometheus required to import.**
71
+
72
+ ---
73
+
74
+ ## Quick start
75
+
76
+ ```bash
77
+ git clone https://github.com/india-energy-atlas/ies-ingest
78
+ cd ies-ingest
79
+ make verify
80
+ ```
81
+
82
+ `make verify`:
83
+
84
+ 1. Runs the test suite (`pytest`, no DB required).
85
+ 2. Runs the Delhi end-to-end example (`python -m ies_ingest.examples.one_state`).
86
+ 3. Prints a sample IES-shaped envelope so you can see the output shape with your own eyes.
87
+
88
+ Expected output:
89
+
90
+ ```json
91
+ {
92
+ "atlas_hour": "2026-05-06T18:00:00+05:30",
93
+ "source_health": "green",
94
+ "data": {
95
+ "state": "delhi",
96
+ "timestamp": "2026-05-06T18:00:00+05:30",
97
+ "demand_mw": 6420.5,
98
+ "source": "metered_sldc",
99
+ "source_kind": "observed"
100
+ }
101
+ }
102
+ ```
103
+
104
+ ---
105
+
106
+ ## Scope, honestly
107
+
108
+ This is not the **whole** SLDC ingestion stack. It is the part that:
109
+
110
+ - ✅ Validates and normalises rows produced by upstream collectors
111
+ - ✅ Stamps every response with a canonical hour + source health
112
+ - ✅ Provides a registry pattern for plugging in new metrics
113
+ - ✅ Maps state-name variants to a canonical key
114
+
115
+ It does **not** include:
116
+
117
+ - ❌ The 33-state SLDC scrapers themselves (httpx / playwright / pdfplumber per-state fetchers). These live in a sibling collector codebase that will be donated separately. Pilots wanting a turn-key collector should watch for `india-energy-atlas/ies-collect` (forthcoming).
118
+ - ❌ Postgres / TimescaleDB schemas. The contract is DB-agnostic by design — bring your own store.
119
+ - ❌ A Prometheus exporter. The metrics surface is a thin convenience; production deployments wire their own.
120
+ - ❌ Modelled-demand fallback (LightGBM tier-2 fill). That requires historical training data that is not yet ours to release.
121
+
122
+ If you need the full pipeline including collectors, [open an issue](https://github.com/india-energy-atlas/ies-ingest/issues) describing the pilot and the state. We will prioritise extraction by demand.
123
+
124
+ ---
125
+
126
+ ## Positioning — what this repo is and is not
127
+
128
+ | | This repo IS | This repo is NOT |
129
+ |---|---|---|
130
+ | Identity | A reference contribution from India Energy Atlas (energymap.in) | India Energy Stack (the Government of India programme led by REC Limited) |
131
+ | Status | Apache 2.0, no certification | An IES-certified component |
132
+ | Authority | We donate the code; we do not speak for IES | The IES specification, signatory, or conformance authority |
133
+ | Use of the IES name | "Produced against IES v0.4 §X (p. NN)" | "IES-compliant" or "IES-certified" |
134
+
135
+ **We never claim to be IES, speak for IES, or certify anything as IES-compliant.** Every claim about conformance is scoped to a specific version of the published v0.4 architecture, with page references.
136
+
137
+ ---
138
+
139
+ ## Mapping to IES v0.4
140
+
141
+ | v0.4 building block | Section | This repo's contribution |
142
+ |---|---|---|
143
+ | Identity & addressability | pp. 15–16 | `canonical_states.py` — first-cut canonicalisation. ERA URN scheme is forthcoming under [IEA-136](https://linear.app/sayon/issue/IEA-136). |
144
+ | Registries & directories | p. 17 | `sources.py` — registry pattern; pluggable per-metric. |
145
+ | Energy credentials | pp. 18–19 | (Out of scope here — see verifier in IEA-135.) |
146
+ | Policies & data | pp. 20–24, 57–58 | `contract.py` enforces a deterministic provenance contract — one of the §"Consistent interpretation" requirements from Annexure 6. |
147
+ | Protocols & schemas | pp. 21–24 | `envelope.py` provides the lightweight Atlas freshness envelope. The cryptographically signed IES envelope (with receipts) lives upstream in the consumer API. |
148
+ | Programme Observability | pp. 26–28 | `health.py` is the Friction surface in nascent form. Adoption + Impact surfaces live upstream. |
149
+
150
+ ---
151
+
152
+ ## Contributing
153
+
154
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full guide. In short:
155
+
156
+ - Open issues for bugs, gaps, or new state-name variants.
157
+ - PRs welcome. Run `make verify` before pushing.
158
+ - Keep the package dependency-light. New runtime deps need a strong justification.
159
+ - Be kind: see [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
160
+
161
+ ---
162
+
163
+ ## Licence
164
+
165
+ - Code: **Apache License 2.0** — see [LICENSE](LICENSE).
166
+ - Documentation in this repo: **CC-BY 4.0**.
167
+ - Original copyright: India Energy Atlas (energymap.in), 2026.
168
+
169
+ See [NOTICE](NOTICE) for attribution.
170
+
171
+ ---
172
+
173
+ ## Acknowledgements
174
+
175
+ - Ministry of Power, REC Limited, FSR Global, ISGF, and the IES Taskforce — for the protocol that makes federated energy data infrastructure possible.
176
+ - Saral Systems Council — the Section 8 non-profit context under which this contribution is offered.
177
+ - All the SLDC operators across India whose hourly publications are the substrate this layer rides on.