greentrain 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,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.4
2
+ Name: greentrain
3
+ Version: 0.1.0
4
+ Summary: Low-carbon AI training service built on iroh-tinker
5
+ License: Apache-2.0
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Intended Audience :: Developers
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: 3.15
16
+ Requires-Python: >=3.10
17
+ Description-Content-Type: text/markdown
18
+ License-File: LICENSE
19
+ Requires-Dist: iroh-tinker>=0.3.0
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=8.0; extra == "dev"
22
+ Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
23
+ Requires-Dist: ruff>=0.5; extra == "dev"
24
+ Requires-Dist: mypy>=1.10; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # greentrain
28
+
29
+ Low-carbon AI training service built on [iroh-tinker](https://github.com/scairesearch/iroh_tinker).
30
+
31
+ greentrain takes a training workload plus its targets (accuracy, latency, cost),
32
+ picks the lowest-carbon device tier and elastic subnet that still meets those
33
+ targets, runs the job through iroh-tinker's multi-cloud launch, and emits an
34
+ auditable carbon report.
35
+
36
+ > **These are estimates unless the report says `measured`.**
37
+ > Every energy and carbon number greentrain prints carries a provenance label.
38
+ > A number is labelled `measured` only when it came from a physical
39
+ > instrument (`nvidia-smi`, Linux RAPL, or an operator-supplied meter). Anything
40
+ > derived from a power model or a grid-intensity dataset is labelled
41
+ > `estimated`. An unlabelled carbon claim is a liability, not a product.
42
+
43
+ ## Install
44
+
45
+ ```bash
46
+ pip install greentrain # released package
47
+ pip install -e ".[dev]" # from a checkout
48
+ ```
49
+
50
+ greentrain depends on the public `iroh-tinker` surface and nothing else.
51
+ While `iroh-tinker` 0.3.0 is unreleased, install it from the working tree:
52
+
53
+ ```bash
54
+ pip install -e /path/to/iroh-tinker
55
+ ```
56
+
57
+ ## Built on the iroh-tinker public surface
58
+
59
+ greentrain uses only published `iroh-tinker` API (verified against
60
+ `iroh-tinker` 0.3.0):
61
+
62
+ | API | Used for |
63
+ |---|---|
64
+ | `iroh_tinker.ofo.SubnetSampler` | elastic width/depth sampling per device tier |
65
+ | `iroh_tinker.ofo.OFAProfile` | per-tier latency/memory profile fed to the sampler |
66
+ | `iroh_tinker.ofo.ElasticConfig` | enabling the elastic width/depth knobs |
67
+ | `iroh_tinker.device.detect_devices` | local tier detection for the fallback power model |
68
+ | `iroh_tinker.hw.HardwareContext` / `infer_topology` | interconnect hints in the tier profile |
69
+ | `iroh_tinker.cloud.spec.LaunchSpec` / `ResourcesSpec` / `RendezvousSpec` / `RecoverySpec` / `CheckpointSpec` | the launch spec greentrain hands to iroh-tinker |
70
+ | `iroh_tinker.cloud.job.JobManager` | launch, status and log collection |
71
+ | `iroh_tinker.comm.CompressedTransport` | gradient transport used by the launched job |
72
+
73
+ `iroh_tinker.AllreduceAlgorithm` is **not** part of the top-level export
74
+ surface; it lives in `iroh_tinker.comm`. greentrain does not depend on it.
75
+
76
+ ## CLI
77
+
78
+ ```bash
79
+ greentrain tiers # tier power models (all estimated)
80
+ greentrain intensity --region eu-north-1
81
+ greentrain plan --spec workload.json # cheapest feasible tier + subnet
82
+ greentrain run --spec workload.json # run it and report the carbon
83
+ greentrain report --job-id my-job # re-render a finished job's report
84
+ ```
85
+
86
+ Every command accepts `--json` for machine consumption.
87
+
88
+ ## Measurement methodology
89
+
90
+ **Energy.** `energy_kwh = average_watts * duration_s / 3_600_000`.
91
+
92
+ The average watts come from the first reader that can produce a reading:
93
+
94
+ 1. `NvidiaSmiPowerReader` — `nvidia-smi --query-gpu=power.draw`. Measured.
95
+ 2. `RaplPowerReader` — Linux RAPL package energy counters under
96
+ `/sys/class/powercap`, differenced over a short interval. Measured.
97
+ 3. `ExternalMeterPowerReader` — an operator-supplied callable returning watts
98
+ from a smart plug, PDU or watt meter. Measured, and the operator's name is
99
+ recorded in the report.
100
+ 4. `EstimatedTierPowerReader` — the documented per-tier power model in
101
+ `greentrain.power.TIER_POWER_MODELS`. **Estimated.**
102
+
103
+ **Carbon.** `carbon_kg = energy_kwh * intensity_gco2_per_kwh / 1000`, using the
104
+ bundled table in `greentrain/data/carbon_intensity.csv`. Each row carries a
105
+ provider, a retrieval date and a source URL. The loader rejects any row
106
+ without a valid date: an undated intensity cannot be audited.
107
+
108
+ The bundled values are annual-average grid figures and are therefore labelled
109
+ `estimated`. They are placeholders until a licensed feed (Ember / WattTime /
110
+ Electricity Maps) is wired in — see "Open questions" in the product-suite plan.
111
+
112
+ ## Provenance contract
113
+
114
+ * `energy_provenance` is the provenance of the power reading.
115
+ * `carbon_provenance` is `measured` **only** when the energy *and* the grid
116
+ intensity were both measured. A modelled energy figure or a dataset
117
+ intensity always downgrades the carbon figure to `estimated`.
118
+ * `greentrain.carbon.check_provenance` raises `ProvenanceViolation` if a
119
+ report ever claims more certainty than its inputs support.
120
+ * Every rendering (JSON, Markdown, Prometheus) carries the label. The JSON
121
+ report has a top-level `measured` boolean that is `true` only when both
122
+ sides of the comparison are measured.
123
+
124
+ ## Subnet selection
125
+
126
+ For each candidate tier greentrain searches the tier's elastic width/depth
127
+ range for the cheapest subnet that still reaches the accuracy target and
128
+ respects the latency and cost targets:
129
+
130
+ ```
131
+ achievable_accuracy = tier_accuracy_floor * width^0.5 * depth^0.5 (capped at 1.0)
132
+ power_factor = clamp(width * depth, 0.35, 1.25)
133
+ estimated_watts = watts_per_device * device_count * power_factor
134
+ ```
135
+
136
+ The accuracy model is a documented heuristic, not a trained predictor. It is
137
+ deliberately conservative: it never lets a tier claim an accuracy it has not
138
+ demonstrated.
139
+
140
+ ## Tests
141
+
142
+ ```bash
143
+ pip install -e ".[dev]"
144
+ pytest
145
+ ```
146
+
147
+ The suite is credential-free. The end-to-end test drives iroh-tinker's **local**
148
+ engine, so it needs no cloud account, no GPU and no network.
149
+
150
+ ## Layout
151
+
152
+ ```
153
+ src/greentrain/
154
+ power.py power readers + provenance labels
155
+ carbon.py accounting, intensity table loader, provenance checks
156
+ data/carbon_intensity.csv dated, sourced grid intensity table
157
+ subnet.py lowest-carbon tier/subnet selection
158
+ report.py JSON / Markdown / Prometheus rendering
159
+ runner.py LaunchSpec + JobManager driver
160
+ cli.py greentrain plan | run | report | tiers | intensity
161
+ ```
162
+
163
+ ## Licence
164
+
165
+ Apache-2.0. greentrain is a separate project from iroh-tinker, which stays
166
+ MIT OR Apache-2.0.
@@ -0,0 +1,140 @@
1
+ # greentrain
2
+
3
+ Low-carbon AI training service built on [iroh-tinker](https://github.com/scairesearch/iroh_tinker).
4
+
5
+ greentrain takes a training workload plus its targets (accuracy, latency, cost),
6
+ picks the lowest-carbon device tier and elastic subnet that still meets those
7
+ targets, runs the job through iroh-tinker's multi-cloud launch, and emits an
8
+ auditable carbon report.
9
+
10
+ > **These are estimates unless the report says `measured`.**
11
+ > Every energy and carbon number greentrain prints carries a provenance label.
12
+ > A number is labelled `measured` only when it came from a physical
13
+ > instrument (`nvidia-smi`, Linux RAPL, or an operator-supplied meter). Anything
14
+ > derived from a power model or a grid-intensity dataset is labelled
15
+ > `estimated`. An unlabelled carbon claim is a liability, not a product.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pip install greentrain # released package
21
+ pip install -e ".[dev]" # from a checkout
22
+ ```
23
+
24
+ greentrain depends on the public `iroh-tinker` surface and nothing else.
25
+ While `iroh-tinker` 0.3.0 is unreleased, install it from the working tree:
26
+
27
+ ```bash
28
+ pip install -e /path/to/iroh-tinker
29
+ ```
30
+
31
+ ## Built on the iroh-tinker public surface
32
+
33
+ greentrain uses only published `iroh-tinker` API (verified against
34
+ `iroh-tinker` 0.3.0):
35
+
36
+ | API | Used for |
37
+ |---|---|
38
+ | `iroh_tinker.ofo.SubnetSampler` | elastic width/depth sampling per device tier |
39
+ | `iroh_tinker.ofo.OFAProfile` | per-tier latency/memory profile fed to the sampler |
40
+ | `iroh_tinker.ofo.ElasticConfig` | enabling the elastic width/depth knobs |
41
+ | `iroh_tinker.device.detect_devices` | local tier detection for the fallback power model |
42
+ | `iroh_tinker.hw.HardwareContext` / `infer_topology` | interconnect hints in the tier profile |
43
+ | `iroh_tinker.cloud.spec.LaunchSpec` / `ResourcesSpec` / `RendezvousSpec` / `RecoverySpec` / `CheckpointSpec` | the launch spec greentrain hands to iroh-tinker |
44
+ | `iroh_tinker.cloud.job.JobManager` | launch, status and log collection |
45
+ | `iroh_tinker.comm.CompressedTransport` | gradient transport used by the launched job |
46
+
47
+ `iroh_tinker.AllreduceAlgorithm` is **not** part of the top-level export
48
+ surface; it lives in `iroh_tinker.comm`. greentrain does not depend on it.
49
+
50
+ ## CLI
51
+
52
+ ```bash
53
+ greentrain tiers # tier power models (all estimated)
54
+ greentrain intensity --region eu-north-1
55
+ greentrain plan --spec workload.json # cheapest feasible tier + subnet
56
+ greentrain run --spec workload.json # run it and report the carbon
57
+ greentrain report --job-id my-job # re-render a finished job's report
58
+ ```
59
+
60
+ Every command accepts `--json` for machine consumption.
61
+
62
+ ## Measurement methodology
63
+
64
+ **Energy.** `energy_kwh = average_watts * duration_s / 3_600_000`.
65
+
66
+ The average watts come from the first reader that can produce a reading:
67
+
68
+ 1. `NvidiaSmiPowerReader` — `nvidia-smi --query-gpu=power.draw`. Measured.
69
+ 2. `RaplPowerReader` — Linux RAPL package energy counters under
70
+ `/sys/class/powercap`, differenced over a short interval. Measured.
71
+ 3. `ExternalMeterPowerReader` — an operator-supplied callable returning watts
72
+ from a smart plug, PDU or watt meter. Measured, and the operator's name is
73
+ recorded in the report.
74
+ 4. `EstimatedTierPowerReader` — the documented per-tier power model in
75
+ `greentrain.power.TIER_POWER_MODELS`. **Estimated.**
76
+
77
+ **Carbon.** `carbon_kg = energy_kwh * intensity_gco2_per_kwh / 1000`, using the
78
+ bundled table in `greentrain/data/carbon_intensity.csv`. Each row carries a
79
+ provider, a retrieval date and a source URL. The loader rejects any row
80
+ without a valid date: an undated intensity cannot be audited.
81
+
82
+ The bundled values are annual-average grid figures and are therefore labelled
83
+ `estimated`. They are placeholders until a licensed feed (Ember / WattTime /
84
+ Electricity Maps) is wired in — see "Open questions" in the product-suite plan.
85
+
86
+ ## Provenance contract
87
+
88
+ * `energy_provenance` is the provenance of the power reading.
89
+ * `carbon_provenance` is `measured` **only** when the energy *and* the grid
90
+ intensity were both measured. A modelled energy figure or a dataset
91
+ intensity always downgrades the carbon figure to `estimated`.
92
+ * `greentrain.carbon.check_provenance` raises `ProvenanceViolation` if a
93
+ report ever claims more certainty than its inputs support.
94
+ * Every rendering (JSON, Markdown, Prometheus) carries the label. The JSON
95
+ report has a top-level `measured` boolean that is `true` only when both
96
+ sides of the comparison are measured.
97
+
98
+ ## Subnet selection
99
+
100
+ For each candidate tier greentrain searches the tier's elastic width/depth
101
+ range for the cheapest subnet that still reaches the accuracy target and
102
+ respects the latency and cost targets:
103
+
104
+ ```
105
+ achievable_accuracy = tier_accuracy_floor * width^0.5 * depth^0.5 (capped at 1.0)
106
+ power_factor = clamp(width * depth, 0.35, 1.25)
107
+ estimated_watts = watts_per_device * device_count * power_factor
108
+ ```
109
+
110
+ The accuracy model is a documented heuristic, not a trained predictor. It is
111
+ deliberately conservative: it never lets a tier claim an accuracy it has not
112
+ demonstrated.
113
+
114
+ ## Tests
115
+
116
+ ```bash
117
+ pip install -e ".[dev]"
118
+ pytest
119
+ ```
120
+
121
+ The suite is credential-free. The end-to-end test drives iroh-tinker's **local**
122
+ engine, so it needs no cloud account, no GPU and no network.
123
+
124
+ ## Layout
125
+
126
+ ```
127
+ src/greentrain/
128
+ power.py power readers + provenance labels
129
+ carbon.py accounting, intensity table loader, provenance checks
130
+ data/carbon_intensity.csv dated, sourced grid intensity table
131
+ subnet.py lowest-carbon tier/subnet selection
132
+ report.py JSON / Markdown / Prometheus rendering
133
+ runner.py LaunchSpec + JobManager driver
134
+ cli.py greentrain plan | run | report | tiers | intensity
135
+ ```
136
+
137
+ ## Licence
138
+
139
+ Apache-2.0. greentrain is a separate project from iroh-tinker, which stays
140
+ MIT OR Apache-2.0.
@@ -0,0 +1,77 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "greentrain"
7
+ version = "0.1.0"
8
+ description = "Low-carbon AI training service built on iroh-tinker"
9
+ readme = "README.md"
10
+ license = {text = "Apache-2.0"}
11
+ requires-python = ">=3.10"
12
+ dependencies = [
13
+ "iroh-tinker>=0.3.0",
14
+ ]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Developers",
18
+ "License :: OSI Approved :: Apache Software License",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Programming Language :: Python :: 3.14",
25
+ "Programming Language :: Python :: 3.15",
26
+ ]
27
+
28
+ [project.scripts]
29
+ greentrain = "greentrain.cli:main"
30
+
31
+ [project.optional-dependencies]
32
+ dev = [
33
+ "pytest>=8.0",
34
+ "pytest-asyncio>=0.23",
35
+ "ruff>=0.5",
36
+ "mypy>=1.10",
37
+ ]
38
+
39
+ [tool.setuptools.packages.find]
40
+ where = ["src"]
41
+
42
+ [tool.setuptools.package-data]
43
+ greentrain = ["py.typed", "data/*.csv"]
44
+
45
+ [tool.ruff]
46
+ line-length = 100
47
+ target-version = "py310"
48
+ src = ["src", "tests"]
49
+
50
+ [tool.ruff.lint]
51
+ select = ["E", "F", "I", "UP", "W", "B", "C4", "PTH", "T20", "TID"]
52
+ ignore = []
53
+
54
+ [tool.ruff.lint.per-file-ignores]
55
+ # The CLI is the one place that is allowed to print.
56
+ "src/greentrain/cli.py" = ["T20"]
57
+
58
+ [tool.mypy]
59
+ python_version = "3.10"
60
+ ignore_missing_imports = true
61
+ warn_return_any = true
62
+ warn_unused_configs = true
63
+ disallow_untyped_defs = true
64
+ disallow_incomplete_defs = true
65
+ check_untyped_defs = true
66
+ no_implicit_optional = true
67
+ strict_optional = true
68
+ warn_redundant_casts = true
69
+ warn_unused_ignores = true
70
+ show_error_codes = true
71
+ pretty = true
72
+
73
+ [tool.pytest.ini_options]
74
+ asyncio_mode = "auto"
75
+ testpaths = ["tests"]
76
+ python_files = ["test_*.py"]
77
+ python_functions = ["test_*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+