psforge-grid 0.1.1__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 (31) hide show
  1. psforge_grid-0.1.1/PKG-INFO +313 -0
  2. psforge_grid-0.1.1/README.md +276 -0
  3. psforge_grid-0.1.1/pyproject.toml +122 -0
  4. psforge_grid-0.1.1/setup.cfg +4 -0
  5. psforge_grid-0.1.1/src/psforge_grid/__init__.py +51 -0
  6. psforge_grid-0.1.1/src/psforge_grid/cli/__init__.py +46 -0
  7. psforge_grid-0.1.1/src/psforge_grid/cli/app.py +622 -0
  8. psforge_grid-0.1.1/src/psforge_grid/cli/formatters.py +591 -0
  9. psforge_grid-0.1.1/src/psforge_grid/io/__init__.py +42 -0
  10. psforge_grid-0.1.1/src/psforge_grid/io/factories.py +179 -0
  11. psforge_grid-0.1.1/src/psforge_grid/io/protocols.py +107 -0
  12. psforge_grid-0.1.1/src/psforge_grid/io/raw_parser.py +780 -0
  13. psforge_grid-0.1.1/src/psforge_grid/models/__init__.py +46 -0
  14. psforge_grid-0.1.1/src/psforge_grid/models/branch.py +143 -0
  15. psforge_grid-0.1.1/src/psforge_grid/models/bus.py +124 -0
  16. psforge_grid-0.1.1/src/psforge_grid/models/enums.py +439 -0
  17. psforge_grid-0.1.1/src/psforge_grid/models/generator.py +147 -0
  18. psforge_grid-0.1.1/src/psforge_grid/models/limits.py +308 -0
  19. psforge_grid-0.1.1/src/psforge_grid/models/load.py +117 -0
  20. psforge_grid-0.1.1/src/psforge_grid/models/shunt.py +114 -0
  21. psforge_grid-0.1.1/src/psforge_grid/models/system.py +523 -0
  22. psforge_grid-0.1.1/src/psforge_grid/py.typed +0 -0
  23. psforge_grid-0.1.1/src/psforge_grid.egg-info/PKG-INFO +313 -0
  24. psforge_grid-0.1.1/src/psforge_grid.egg-info/SOURCES.txt +29 -0
  25. psforge_grid-0.1.1/src/psforge_grid.egg-info/dependency_links.txt +1 -0
  26. psforge_grid-0.1.1/src/psforge_grid.egg-info/entry_points.txt +2 -0
  27. psforge_grid-0.1.1/src/psforge_grid.egg-info/requires.txt +12 -0
  28. psforge_grid-0.1.1/src/psforge_grid.egg-info/top_level.txt +1 -0
  29. psforge_grid-0.1.1/tests/test_import.py +6 -0
  30. psforge_grid-0.1.1/tests/test_models.py +482 -0
  31. psforge_grid-0.1.1/tests/test_raw_parser.py +263 -0
@@ -0,0 +1,313 @@
1
+ Metadata-Version: 2.4
2
+ Name: psforge-grid
3
+ Version: 0.1.1
4
+ Summary: Core data models and I/O for the psforge power system analysis ecosystem. LLM-friendly design for AI-assisted analysis.
5
+ Author-email: Manabe Lab LLC <manabe@manabelab.com>
6
+ Maintainer-email: Manabe Lab LLC <manabe@manabelab.com>
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/manabelab/psforge-grid
9
+ Project-URL: Documentation, https://github.com/manabelab/psforge-grid#readme
10
+ Project-URL: Repository, https://github.com/manabelab/psforge-grid.git
11
+ Project-URL: Changelog, https://github.com/manabelab/psforge-grid/blob/main/CHANGELOG.md
12
+ Project-URL: Bug Tracker, https://github.com/manabelab/psforge-grid/issues
13
+ Keywords: power-systems,electrical-engineering,psse,power-flow,grid,llm-friendly,education,energy
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Education
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Scientific/Engineering
24
+ Classifier: Topic :: Scientific/Engineering :: Physics
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.9
27
+ Description-Content-Type: text/markdown
28
+ Requires-Dist: typer>=0.9.0
29
+ Requires-Dist: rich>=13.0.0
30
+ Provides-Extra: slim
31
+ Provides-Extra: cli
32
+ Provides-Extra: dev
33
+ Requires-Dist: pytest; extra == "dev"
34
+ Requires-Dist: ruff; extra == "dev"
35
+ Requires-Dist: mypy; extra == "dev"
36
+ Requires-Dist: pre-commit; extra == "dev"
37
+
38
+ # psforge-grid
39
+
40
+ [![PyPI version](https://badge.fury.io/py/psforge-grid.svg)](https://badge.fury.io/py/psforge-grid)
41
+ [![Python versions](https://img.shields.io/pypi/pyversions/psforge-grid.svg)](https://pypi.org/project/psforge-grid/)
42
+ [![Tests](https://github.com/manabelab/psforge-grid/actions/workflows/test.yml/badge.svg)](https://github.com/manabelab/psforge-grid/actions/workflows/test.yml)
43
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44
+
45
+ > **Hub data model for the psforge power system analysis ecosystem**
46
+
47
+ Core data models and I/O for power system analysis with LLM-friendly design.
48
+
49
+ ## Quick Start
50
+
51
+ ```bash
52
+ pip install psforge-grid
53
+ ```
54
+
55
+ ```python
56
+ from psforge_grid import System
57
+
58
+ # Load a PSS/E RAW file
59
+ system = System.from_raw("ieee14.raw")
60
+
61
+ # Explore the system
62
+ print(f"Buses: {len(system.buses)}, Branches: {len(system.branches)}")
63
+
64
+ # Get LLM-friendly summary
65
+ print(system.to_summary())
66
+ ```
67
+
68
+ ```bash
69
+ # Or use the CLI
70
+ psforge-grid info ieee14.raw
71
+ psforge-grid show ieee14.raw buses -f json
72
+ ```
73
+
74
+ ## Why psforge-grid?
75
+
76
+ | Feature | psforge-grid | Others |
77
+ |---------|--------------|--------|
78
+ | **LLM-friendly output** | Built-in JSON/summary formats | Manual formatting |
79
+ | **Educational design** | Rich docstrings, clear naming | Varies |
80
+ | **Type hints** | Complete type annotations | Often missing |
81
+ | **CLI included** | Yes, with multiple output formats | Usually separate |
82
+ | **PSS/E RAW support** | v33/v34 core sections | Varies |
83
+
84
+ ## Overview
85
+
86
+ psforge-grid serves as the **Hub** of the psforge ecosystem, providing:
87
+
88
+ - Common data classes (`System`, `Bus`, `Branch`, `Generator`, `Load`, `Shunt`)
89
+ - PSS/E RAW file parser (v33/v34 partial support)
90
+ - Shared utilities for power system analysis
91
+
92
+ ## LLM Affinity Design
93
+
94
+ > **"Pickaxe in the Gold Rush"** - psforge is designed for seamless LLM integration.
95
+
96
+ psforge-grid implements LLM-friendly data structures and CLI:
97
+
98
+ | Feature | Description |
99
+ |---------|-------------|
100
+ | **Explicit Units** | Field names include units (`voltage_pu`, `power_mw`) |
101
+ | **Semantic Status** | Enum-based status annotations (`VoltageStatus.LOW`) |
102
+ | **Self-Documenting** | Rich docstrings explaining physical meaning |
103
+ | **to_description()** | Human/LLM-readable output methods |
104
+
105
+ ```python
106
+ # Example: LLM-friendly bus description
107
+ bus = system.get_bus(14)
108
+ print(bus.to_description())
109
+ # Output: "Bus 14 (LOAD_BUS): 13.8 kV, PQ type"
110
+ ```
111
+
112
+ ### CLI for LLM Integration
113
+
114
+ psforge-grid includes a CLI designed for LLM-friendly output:
115
+
116
+ ```bash
117
+ # System summary in different formats
118
+ psforge-grid info ieee14.raw # Table format
119
+ psforge-grid info ieee14.raw -f json # JSON for API/LLM
120
+ psforge-grid info ieee14.raw -f summary # Compact for tokens
121
+
122
+ # Display element details
123
+ psforge-grid show ieee14.raw buses
124
+ psforge-grid show ieee14.raw branches -f json
125
+
126
+ # Validate system data
127
+ psforge-grid validate ieee14.raw
128
+ psforge-grid validate ieee14.raw --strict
129
+ ```
130
+
131
+ **Output Formats:**
132
+ - `table`: Human-readable tables (default)
133
+ - `json`: Structured JSON for LLM/API processing
134
+ - `summary`: Compact text for token-efficient LLM usage
135
+ - `csv`: Comma-separated values for data analysis
136
+
137
+ See [CLAUDE.md](CLAUDE.md) for detailed AI development guidelines.
138
+
139
+ ## PSS/E RAW Format Support
140
+
141
+ ### Current Status
142
+
143
+ The parser supports **core power flow data** required for basic AC power flow analysis:
144
+
145
+ | Section | v33 | v34 | Notes |
146
+ |---------|-----|-----|-------|
147
+ | Case Identification | Yes | Yes | Base MVA, system info |
148
+ | Bus Data | Yes | Yes | All bus types (PQ, PV, Slack, Isolated) |
149
+ | Load Data | Yes | Yes | Constant power loads |
150
+ | Fixed Shunt Data | Yes | Yes | Capacitors and reactors |
151
+ | Generator Data | Yes | Yes | P, Q, voltage setpoint, Q limits |
152
+ | Branch Data | Yes | Yes | Transmission lines |
153
+ | Transformer Data | Yes | Yes | Two-winding transformers only |
154
+
155
+ ### Not Yet Supported
156
+
157
+ The following sections are parsed but ignored (data is skipped):
158
+
159
+ - Area Data, Zone Data, Owner Data
160
+ - Two-Terminal DC Data, Multi-Terminal DC Data
161
+ - VSC DC Line Data, FACTS Device Data
162
+ - Switched Shunt Data (use Fixed Shunt instead)
163
+ - Multi-Section Line Data, Impedance Correction Data
164
+ - GNE Data, Induction Machine Data, Substation Data
165
+ - Three-winding Transformers
166
+
167
+ ### Test Data Sources
168
+
169
+ Parser has been validated with IEEE test cases from multiple sources:
170
+
171
+ - IEEE 9-bus (v34): [GitHub - todstewart1001](https://github.com/todstewart1001/PSSE-24-Hour-Load-Dispatch-IEEE-9-Bus-System-)
172
+ - IEEE 14-bus (v33): [GitHub - ITI/models](https://github.com/ITI/models/blob/master/electric-grid/physical/reference/ieee-14bus/)
173
+ - IEEE 118-bus (v33): [GitHub - powsybl](https://github.com/powsybl/powsybl-distribution/blob/main/resources/PSSE/IEEE_118_bus.raw)
174
+
175
+ ### Future Plans
176
+
177
+ 1. **Phase 2**: Three-winding transformer support
178
+ 2. **Phase 3**: Switched shunt data support
179
+ 3. **Future**: HVDC, FACTS device support (as needed)
180
+
181
+ ## Installation
182
+
183
+ ```bash
184
+ # Install the package
185
+ pip install psforge-grid
186
+
187
+ # Or install from source
188
+ pip install -e .
189
+ ```
190
+
191
+ ## Development Setup
192
+
193
+ ### Prerequisites
194
+
195
+ - Python 3.9+
196
+ - [uv](https://github.com/astral-sh/uv) (recommended) or pip
197
+
198
+ ### Install Development Dependencies
199
+
200
+ ```bash
201
+ # Using uv (recommended)
202
+ uv pip install -e ".[dev]"
203
+
204
+ # Or using pip
205
+ pip install -e ".[dev]"
206
+ ```
207
+
208
+ ### Setup Pre-commit Hooks
209
+
210
+ Pre-commit hooks automatically run ruff and mypy checks before each commit.
211
+
212
+ #### Option 1: Global Install with pipx (Recommended)
213
+
214
+ Using [pipx](https://github.com/pypa/pipx) for global installation is recommended, especially when using **git worktree** for parallel development. This ensures `pre-commit` is available across all worktrees without additional setup.
215
+
216
+ ```bash
217
+ # Install pipx if not already installed
218
+ brew install pipx # macOS
219
+ # or: pip install --user pipx
220
+
221
+ # Install pre-commit globally
222
+ pipx install pre-commit
223
+
224
+ # Install hooks (only needed once per repository)
225
+ pre-commit install
226
+
227
+ # Run hooks manually on all files
228
+ pre-commit run --all-files
229
+ ```
230
+
231
+ **Why pipx?**
232
+ - Works across all git worktrees without per-worktree setup
233
+ - Isolated environment prevents dependency conflicts
234
+ - Single installation, works everywhere
235
+
236
+ #### Option 2: Local Install in Virtual Environment
237
+
238
+ ```bash
239
+ # Install pre-commit in your virtual environment
240
+ pip install pre-commit
241
+
242
+ # Install hooks
243
+ pre-commit install
244
+
245
+ # Run hooks manually on all files
246
+ pre-commit run --all-files
247
+ ```
248
+
249
+ > **Note:** CI runs ruff and mypy checks via GitHub Actions (`.github/workflows/test.yml`), so code quality is enforced on push/PR even if local hooks are skipped.
250
+
251
+ ### Manual Code Quality Checks
252
+
253
+ ```bash
254
+ # Lint with ruff
255
+ ruff check src/ tests/
256
+
257
+ # Format with ruff
258
+ ruff format src/ tests/
259
+
260
+ # Type check with mypy
261
+ mypy src/
262
+ ```
263
+
264
+ ### Run Tests
265
+
266
+ ```bash
267
+ pytest tests/ -v
268
+ ```
269
+
270
+ ### Editor Setup (VSCode/Cursor)
271
+
272
+ This project includes `.vscode/` configuration for seamless development:
273
+
274
+ - **Format on Save**: Automatically formats code with ruff
275
+ - **Organize Imports**: Automatically sorts imports
276
+ - **Type Checking**: Mypy extension provides real-time type checking
277
+
278
+ **Recommended Extensions:**
279
+ - `charliermarsh.ruff` - Ruff linter and formatter
280
+ - `ms-python.mypy-type-checker` - Mypy type checker
281
+ - `ms-python.python` - Python language support
282
+
283
+ ## Related Projects
284
+
285
+ psforge is a modular power system analysis ecosystem:
286
+
287
+ | Package | Description | Status |
288
+ |---------|-------------|--------|
289
+ | **psforge-grid** (this) | Core data models and I/O (Hub) | Active |
290
+ | [psforge-flow](https://github.com/manabelab/psforge-flow) | AC power flow calculation | Active |
291
+ | psforge-stability | Transient stability analysis | Planned |
292
+ | psforge-schedule | Unit commitment optimization | Planned |
293
+
294
+ ## Contributing
295
+
296
+ Contributions are welcome! Please feel free to submit a Pull Request.
297
+
298
+ 1. Fork the repository
299
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
300
+ 3. Run tests (`pytest tests/`)
301
+ 4. Commit your changes (`git commit -m 'Add amazing feature'`)
302
+ 5. Push to the branch (`git push origin feature/amazing-feature`)
303
+ 6. Open a Pull Request
304
+
305
+ See [CLAUDE.md](CLAUDE.md) for AI development guidelines.
306
+
307
+ ## License
308
+
309
+ MIT License - see [LICENSE](LICENSE) for details.
310
+
311
+ ---
312
+
313
+ **Developed by [Manabe Lab LLC](https://github.com/manabelab)**
@@ -0,0 +1,276 @@
1
+ # psforge-grid
2
+
3
+ [![PyPI version](https://badge.fury.io/py/psforge-grid.svg)](https://badge.fury.io/py/psforge-grid)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/psforge-grid.svg)](https://pypi.org/project/psforge-grid/)
5
+ [![Tests](https://github.com/manabelab/psforge-grid/actions/workflows/test.yml/badge.svg)](https://github.com/manabelab/psforge-grid/actions/workflows/test.yml)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ > **Hub data model for the psforge power system analysis ecosystem**
9
+
10
+ Core data models and I/O for power system analysis with LLM-friendly design.
11
+
12
+ ## Quick Start
13
+
14
+ ```bash
15
+ pip install psforge-grid
16
+ ```
17
+
18
+ ```python
19
+ from psforge_grid import System
20
+
21
+ # Load a PSS/E RAW file
22
+ system = System.from_raw("ieee14.raw")
23
+
24
+ # Explore the system
25
+ print(f"Buses: {len(system.buses)}, Branches: {len(system.branches)}")
26
+
27
+ # Get LLM-friendly summary
28
+ print(system.to_summary())
29
+ ```
30
+
31
+ ```bash
32
+ # Or use the CLI
33
+ psforge-grid info ieee14.raw
34
+ psforge-grid show ieee14.raw buses -f json
35
+ ```
36
+
37
+ ## Why psforge-grid?
38
+
39
+ | Feature | psforge-grid | Others |
40
+ |---------|--------------|--------|
41
+ | **LLM-friendly output** | Built-in JSON/summary formats | Manual formatting |
42
+ | **Educational design** | Rich docstrings, clear naming | Varies |
43
+ | **Type hints** | Complete type annotations | Often missing |
44
+ | **CLI included** | Yes, with multiple output formats | Usually separate |
45
+ | **PSS/E RAW support** | v33/v34 core sections | Varies |
46
+
47
+ ## Overview
48
+
49
+ psforge-grid serves as the **Hub** of the psforge ecosystem, providing:
50
+
51
+ - Common data classes (`System`, `Bus`, `Branch`, `Generator`, `Load`, `Shunt`)
52
+ - PSS/E RAW file parser (v33/v34 partial support)
53
+ - Shared utilities for power system analysis
54
+
55
+ ## LLM Affinity Design
56
+
57
+ > **"Pickaxe in the Gold Rush"** - psforge is designed for seamless LLM integration.
58
+
59
+ psforge-grid implements LLM-friendly data structures and CLI:
60
+
61
+ | Feature | Description |
62
+ |---------|-------------|
63
+ | **Explicit Units** | Field names include units (`voltage_pu`, `power_mw`) |
64
+ | **Semantic Status** | Enum-based status annotations (`VoltageStatus.LOW`) |
65
+ | **Self-Documenting** | Rich docstrings explaining physical meaning |
66
+ | **to_description()** | Human/LLM-readable output methods |
67
+
68
+ ```python
69
+ # Example: LLM-friendly bus description
70
+ bus = system.get_bus(14)
71
+ print(bus.to_description())
72
+ # Output: "Bus 14 (LOAD_BUS): 13.8 kV, PQ type"
73
+ ```
74
+
75
+ ### CLI for LLM Integration
76
+
77
+ psforge-grid includes a CLI designed for LLM-friendly output:
78
+
79
+ ```bash
80
+ # System summary in different formats
81
+ psforge-grid info ieee14.raw # Table format
82
+ psforge-grid info ieee14.raw -f json # JSON for API/LLM
83
+ psforge-grid info ieee14.raw -f summary # Compact for tokens
84
+
85
+ # Display element details
86
+ psforge-grid show ieee14.raw buses
87
+ psforge-grid show ieee14.raw branches -f json
88
+
89
+ # Validate system data
90
+ psforge-grid validate ieee14.raw
91
+ psforge-grid validate ieee14.raw --strict
92
+ ```
93
+
94
+ **Output Formats:**
95
+ - `table`: Human-readable tables (default)
96
+ - `json`: Structured JSON for LLM/API processing
97
+ - `summary`: Compact text for token-efficient LLM usage
98
+ - `csv`: Comma-separated values for data analysis
99
+
100
+ See [CLAUDE.md](CLAUDE.md) for detailed AI development guidelines.
101
+
102
+ ## PSS/E RAW Format Support
103
+
104
+ ### Current Status
105
+
106
+ The parser supports **core power flow data** required for basic AC power flow analysis:
107
+
108
+ | Section | v33 | v34 | Notes |
109
+ |---------|-----|-----|-------|
110
+ | Case Identification | Yes | Yes | Base MVA, system info |
111
+ | Bus Data | Yes | Yes | All bus types (PQ, PV, Slack, Isolated) |
112
+ | Load Data | Yes | Yes | Constant power loads |
113
+ | Fixed Shunt Data | Yes | Yes | Capacitors and reactors |
114
+ | Generator Data | Yes | Yes | P, Q, voltage setpoint, Q limits |
115
+ | Branch Data | Yes | Yes | Transmission lines |
116
+ | Transformer Data | Yes | Yes | Two-winding transformers only |
117
+
118
+ ### Not Yet Supported
119
+
120
+ The following sections are parsed but ignored (data is skipped):
121
+
122
+ - Area Data, Zone Data, Owner Data
123
+ - Two-Terminal DC Data, Multi-Terminal DC Data
124
+ - VSC DC Line Data, FACTS Device Data
125
+ - Switched Shunt Data (use Fixed Shunt instead)
126
+ - Multi-Section Line Data, Impedance Correction Data
127
+ - GNE Data, Induction Machine Data, Substation Data
128
+ - Three-winding Transformers
129
+
130
+ ### Test Data Sources
131
+
132
+ Parser has been validated with IEEE test cases from multiple sources:
133
+
134
+ - IEEE 9-bus (v34): [GitHub - todstewart1001](https://github.com/todstewart1001/PSSE-24-Hour-Load-Dispatch-IEEE-9-Bus-System-)
135
+ - IEEE 14-bus (v33): [GitHub - ITI/models](https://github.com/ITI/models/blob/master/electric-grid/physical/reference/ieee-14bus/)
136
+ - IEEE 118-bus (v33): [GitHub - powsybl](https://github.com/powsybl/powsybl-distribution/blob/main/resources/PSSE/IEEE_118_bus.raw)
137
+
138
+ ### Future Plans
139
+
140
+ 1. **Phase 2**: Three-winding transformer support
141
+ 2. **Phase 3**: Switched shunt data support
142
+ 3. **Future**: HVDC, FACTS device support (as needed)
143
+
144
+ ## Installation
145
+
146
+ ```bash
147
+ # Install the package
148
+ pip install psforge-grid
149
+
150
+ # Or install from source
151
+ pip install -e .
152
+ ```
153
+
154
+ ## Development Setup
155
+
156
+ ### Prerequisites
157
+
158
+ - Python 3.9+
159
+ - [uv](https://github.com/astral-sh/uv) (recommended) or pip
160
+
161
+ ### Install Development Dependencies
162
+
163
+ ```bash
164
+ # Using uv (recommended)
165
+ uv pip install -e ".[dev]"
166
+
167
+ # Or using pip
168
+ pip install -e ".[dev]"
169
+ ```
170
+
171
+ ### Setup Pre-commit Hooks
172
+
173
+ Pre-commit hooks automatically run ruff and mypy checks before each commit.
174
+
175
+ #### Option 1: Global Install with pipx (Recommended)
176
+
177
+ Using [pipx](https://github.com/pypa/pipx) for global installation is recommended, especially when using **git worktree** for parallel development. This ensures `pre-commit` is available across all worktrees without additional setup.
178
+
179
+ ```bash
180
+ # Install pipx if not already installed
181
+ brew install pipx # macOS
182
+ # or: pip install --user pipx
183
+
184
+ # Install pre-commit globally
185
+ pipx install pre-commit
186
+
187
+ # Install hooks (only needed once per repository)
188
+ pre-commit install
189
+
190
+ # Run hooks manually on all files
191
+ pre-commit run --all-files
192
+ ```
193
+
194
+ **Why pipx?**
195
+ - Works across all git worktrees without per-worktree setup
196
+ - Isolated environment prevents dependency conflicts
197
+ - Single installation, works everywhere
198
+
199
+ #### Option 2: Local Install in Virtual Environment
200
+
201
+ ```bash
202
+ # Install pre-commit in your virtual environment
203
+ pip install pre-commit
204
+
205
+ # Install hooks
206
+ pre-commit install
207
+
208
+ # Run hooks manually on all files
209
+ pre-commit run --all-files
210
+ ```
211
+
212
+ > **Note:** CI runs ruff and mypy checks via GitHub Actions (`.github/workflows/test.yml`), so code quality is enforced on push/PR even if local hooks are skipped.
213
+
214
+ ### Manual Code Quality Checks
215
+
216
+ ```bash
217
+ # Lint with ruff
218
+ ruff check src/ tests/
219
+
220
+ # Format with ruff
221
+ ruff format src/ tests/
222
+
223
+ # Type check with mypy
224
+ mypy src/
225
+ ```
226
+
227
+ ### Run Tests
228
+
229
+ ```bash
230
+ pytest tests/ -v
231
+ ```
232
+
233
+ ### Editor Setup (VSCode/Cursor)
234
+
235
+ This project includes `.vscode/` configuration for seamless development:
236
+
237
+ - **Format on Save**: Automatically formats code with ruff
238
+ - **Organize Imports**: Automatically sorts imports
239
+ - **Type Checking**: Mypy extension provides real-time type checking
240
+
241
+ **Recommended Extensions:**
242
+ - `charliermarsh.ruff` - Ruff linter and formatter
243
+ - `ms-python.mypy-type-checker` - Mypy type checker
244
+ - `ms-python.python` - Python language support
245
+
246
+ ## Related Projects
247
+
248
+ psforge is a modular power system analysis ecosystem:
249
+
250
+ | Package | Description | Status |
251
+ |---------|-------------|--------|
252
+ | **psforge-grid** (this) | Core data models and I/O (Hub) | Active |
253
+ | [psforge-flow](https://github.com/manabelab/psforge-flow) | AC power flow calculation | Active |
254
+ | psforge-stability | Transient stability analysis | Planned |
255
+ | psforge-schedule | Unit commitment optimization | Planned |
256
+
257
+ ## Contributing
258
+
259
+ Contributions are welcome! Please feel free to submit a Pull Request.
260
+
261
+ 1. Fork the repository
262
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
263
+ 3. Run tests (`pytest tests/`)
264
+ 4. Commit your changes (`git commit -m 'Add amazing feature'`)
265
+ 5. Push to the branch (`git push origin feature/amazing-feature`)
266
+ 6. Open a Pull Request
267
+
268
+ See [CLAUDE.md](CLAUDE.md) for AI development guidelines.
269
+
270
+ ## License
271
+
272
+ MIT License - see [LICENSE](LICENSE) for details.
273
+
274
+ ---
275
+
276
+ **Developed by [Manabe Lab LLC](https://github.com/manabelab)**
@@ -0,0 +1,122 @@
1
+ # psforge-grid/pyproject.toml
2
+
3
+ [build-system]
4
+ requires = ["setuptools>=61.0"]
5
+ build-backend = "setuptools.build_meta"
6
+
7
+ [project]
8
+ name = "psforge-grid"
9
+ version = "0.1.1"
10
+ description = "Core data models and I/O for the psforge power system analysis ecosystem. LLM-friendly design for AI-assisted analysis."
11
+ readme = "README.md"
12
+ license = "MIT"
13
+ requires-python = ">=3.9"
14
+ authors = [
15
+ { name = "Manabe Lab LLC", email = "manabe@manabelab.com" }
16
+ ]
17
+ maintainers = [
18
+ { name = "Manabe Lab LLC", email = "manabe@manabelab.com" }
19
+ ]
20
+ keywords = [
21
+ "power-systems",
22
+ "electrical-engineering",
23
+ "psse",
24
+ "power-flow",
25
+ "grid",
26
+ "llm-friendly",
27
+ "education",
28
+ "energy",
29
+ ]
30
+ classifiers = [
31
+ "Development Status :: 4 - Beta",
32
+ "Intended Audience :: Education",
33
+ "Intended Audience :: Science/Research",
34
+ "Operating System :: OS Independent",
35
+ "Programming Language :: Python :: 3",
36
+ "Programming Language :: Python :: 3.9",
37
+ "Programming Language :: Python :: 3.10",
38
+ "Programming Language :: Python :: 3.11",
39
+ "Programming Language :: Python :: 3.12",
40
+ "Topic :: Scientific/Engineering",
41
+ "Topic :: Scientific/Engineering :: Physics",
42
+ "Typing :: Typed",
43
+ ]
44
+ # Dependencies - CLI tools (typer/rich) are included by default for immediate usability
45
+ dependencies = [
46
+ "typer>=0.9.0",
47
+ "rich>=13.0.0",
48
+ ]
49
+
50
+ [project.urls]
51
+ Homepage = "https://github.com/manabelab/psforge-grid"
52
+ Documentation = "https://github.com/manabelab/psforge-grid#readme"
53
+ Repository = "https://github.com/manabelab/psforge-grid.git"
54
+ Changelog = "https://github.com/manabelab/psforge-grid/blob/main/CHANGELOG.md"
55
+ "Bug Tracker" = "https://github.com/manabelab/psforge-grid/issues"
56
+
57
+ [project.optional-dependencies]
58
+ # Slim install without CLI dependencies (for embedding in other packages)
59
+ slim = []
60
+ # Backward compatibility: cli extra is now empty since CLI is included by default
61
+ cli = []
62
+ dev = [
63
+ "pytest",
64
+ "ruff", # Linter/Formatter
65
+ "mypy", # Type checker
66
+ "pre-commit", # Git hooks for automatic checks
67
+ ]
68
+
69
+ [project.scripts]
70
+ psforge-grid = "psforge_grid.cli:main"
71
+
72
+ [tool.setuptools.packages.find]
73
+ where = ["src"] # Source code is in the 'src' directory
74
+
75
+ # Ruff configuration
76
+ [tool.ruff]
77
+ line-length = 100
78
+ target-version = "py39"
79
+
80
+ [tool.ruff.lint]
81
+ select = [
82
+ "E", # pycodestyle errors
83
+ "W", # pycodestyle warnings
84
+ "F", # pyflakes
85
+ "I", # isort
86
+ "B", # flake8-bugbear
87
+ "C4", # flake8-comprehensions
88
+ "UP", # pyupgrade
89
+ "ARG", # flake8-unused-arguments
90
+ "SIM", # flake8-simplify
91
+ ]
92
+ ignore = [
93
+ "E501", # line too long (handled by formatter)
94
+ ]
95
+
96
+ [tool.ruff.lint.isort]
97
+ known-first-party = ["psforge_grid"]
98
+
99
+ [tool.ruff.format]
100
+ quote-style = "double"
101
+ indent-style = "space"
102
+
103
+ # Mypy configuration
104
+ [tool.mypy]
105
+ python_version = "3.9"
106
+ warn_return_any = true
107
+ warn_unused_configs = true
108
+ disallow_untyped_defs = false
109
+ disallow_incomplete_defs = false
110
+ check_untyped_defs = true
111
+ no_implicit_optional = true
112
+ warn_redundant_casts = true
113
+ warn_unused_ignores = true
114
+ warn_no_return = true
115
+ strict_equality = true
116
+ show_error_codes = true
117
+ ignore_missing_imports = true
118
+ exclude = ["site-packages"]
119
+
120
+ [[tool.mypy.overrides]]
121
+ module = "tests.*"
122
+ disallow_untyped_defs = false