gemseo-gantry 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.
- gemseo_gantry-0.1.0/LICENSE +21 -0
- gemseo_gantry-0.1.0/PKG-INFO +144 -0
- gemseo_gantry-0.1.0/README.md +109 -0
- gemseo_gantry-0.1.0/pyproject.toml +105 -0
- gemseo_gantry-0.1.0/pyproject.toml.orig +91 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/__init__.py +44 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/__main__.py +6 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/artifacts.py +35 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/__init__.py +0 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/_artifacts.py +11 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/_common.py +134 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/_render.py +259 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/_result.py +77 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/_walkthrough.py +258 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/build.py +181 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/diagram.py +254 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/example.py +183 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/init.py +106 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/main.py +28 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/scaffold.py +290 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/schema.py +89 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/templates/problem.toml +78 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/cli/validate.py +205 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/diagram/__init__.py +3 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/diagram/diagram.py +108 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/__init__.py +0 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/narration.py +121 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/registry.py +74 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/runner.py +160 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/__init__.py +0 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/disciplines/Sellar1.py +27 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/disciplines/Sellar2.py +26 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/disciplines/SellarSystem.py +34 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/disciplines/__init__.py +0 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/execute_Sellar.py +32 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/meta.py +32 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/postprocess.py +18 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sellar/sellar.toml +98 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/__init__.py +0 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/disciplines/Aerodynamics.py +21 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/disciplines/Mission.py +15 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/disciplines/Propulsion.py +21 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/disciplines/Structure.py +21 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/disciplines/__init__.py +0 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/execute_SystemScenario.py +72 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/meta.py +40 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/postprocess.py +18 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/examples/sobieski/sobieski.toml +243 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/__init__.py +4 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/lib_generator.py +523 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/scaffold_generator.py +419 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/templates/discipline_base.jinja +21 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/templates/discipline_io.jinja +36 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/templates/discipline_scaffold.jinja +37 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/templates/execute_scaffold.jinja +58 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/templates/grammar.jinja +26 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/templates/load_scenario.jinja +15 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/templates/scenario.jinja +98 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/templates/variables.jinja +11 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/generator/utils.py +15 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/model/__init__.py +0 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/model/data_model.py +242 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/parser/__init__.py +3 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/parser/toml_data_model.py +62 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/parser/toml_parser.py +102 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/parser/utils.py +39 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/schema.py +42 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/validation/__init__.py +3 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/validation/pipeline.py +60 -0
- gemseo_gantry-0.1.0/src/gemseo_gantry/validation/semantic.py +610 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Axel Widenfelt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gemseo-gantry
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate GEMSEO glue code for MDAO problems from a TOML problem definition.
|
|
5
|
+
Keywords: gemseo,mdao,mdo,optimization,code-generation
|
|
6
|
+
Author: Axel Widenfelt
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering
|
|
12
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Requires-Dist: jinja2>=3.1.6
|
|
19
|
+
Requires-Dist: lazy-loader>=0.4
|
|
20
|
+
Requires-Dist: pandas>=2.3.2
|
|
21
|
+
Requires-Dist: pydantic>=2.11.9
|
|
22
|
+
Requires-Dist: python-slugify>=8.0.4
|
|
23
|
+
Requires-Dist: black>=25.1.0
|
|
24
|
+
Requires-Dist: isort>=6.0.1
|
|
25
|
+
Requires-Dist: gemseo[all]>=6.3.0,<7
|
|
26
|
+
Requires-Dist: typer>=0.15.0
|
|
27
|
+
Requires-Dist: rich>=13.0.0
|
|
28
|
+
Requires-Dist: watchfiles>=0.21
|
|
29
|
+
Requires-Dist: readchar>=4.2.2
|
|
30
|
+
Requires-Python: >=3.11
|
|
31
|
+
Project-URL: Homepage, https://github.com/axwide/gantry
|
|
32
|
+
Project-URL: Documentation, https://github.com/axwide/gantry/tree/main/docs
|
|
33
|
+
Project-URL: Issues, https://github.com/axwide/gantry/issues
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# gemseo-gantry
|
|
37
|
+
|
|
38
|
+
[](https://github.com/axwide/gantry/actions/workflows/ci.yml)
|
|
39
|
+
[](https://pypi.org/project/gemseo-gantry/)
|
|
40
|
+
[](https://pypi.org/project/gemseo-gantry/)
|
|
41
|
+
[](https://gemseo.readthedocs.io/)
|
|
42
|
+
[](https://github.com/axwide/gantry/blob/main/LICENSE)
|
|
43
|
+
[](https://github.com/astral-sh/ruff)
|
|
44
|
+
[](https://github.com/astral-sh/uv)
|
|
45
|
+
[](https://docs.basedpyright.com/)
|
|
46
|
+
|
|
47
|
+
**Generate GEMSEO glue code for MDAO problems from a TOML problem definition.**
|
|
48
|
+
|
|
49
|
+
`gemseo-gantry` takes one diffable TOML file describing your problem and generates the GEMSEO boilerplate you'd otherwise write by hand: typed I/O dataclasses, grammars, a design space, a variables enum, discipline base classes and scenario construction. The TOML is the source of truth. When the problem changes you regenerate, and your type checker points at the hand-written code that needs updating.
|
|
50
|
+
|
|
51
|
+
> [!NOTE]
|
|
52
|
+
> `gemseo-gantry` is pre-1.0. Expect rough edges, and expect details to change between releases.
|
|
53
|
+
|
|
54
|
+
## Features
|
|
55
|
+
|
|
56
|
+
- **One source of truth.** Variables, disciplines and scenarios all live in one TOML file. Variable roles such as design variable or coupling are inferred, so you don't declare them twice.
|
|
57
|
+
- **Safe regeneration.** `gantry build` rebuilds a disposable `lib/` package. `gantry scaffold` writes your discipline and executor files once and never touches them again.
|
|
58
|
+
- **The type checker does the reconciling.** Rename or split a variable and rebuild. Code of yours that no longer matches shows up as a type or import error right where it needs changing.
|
|
59
|
+
- **Fast feedback.** `gantry validate --watch` re-checks the problem every time you save. A generated JSON Schema gives you autocomplete and validation in TOML-aware editors.
|
|
60
|
+
- **Diagrams.** N2 and XDSM views of the coupling topology, drawn straight from the TOML.
|
|
61
|
+
- **Scriptable.** Every command takes `--json` for machine-readable output.
|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
uv tool install gemseo-gantry
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
This puts the `gantry` command on your path.
|
|
70
|
+
|
|
71
|
+
## Quickstart
|
|
72
|
+
|
|
73
|
+
To see the whole pipeline, generate the Sellar example. It's a classic benchmark, and you get a complete project you can run:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
gantry example sellar # add --explain to narrate each stage
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or start your own problem:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
gantry init # 1. write a starter problem.toml (plus its JSON Schema)
|
|
83
|
+
gantry validate --watch # 2. edit problem.toml with live feedback (q/Esc to stop)
|
|
84
|
+
gantry build # 3. generate the disposable lib/ package
|
|
85
|
+
gantry scaffold # 4. write your discipline stubs and scenario executor, once
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Then fill in the physics. A scaffolded discipline is a thin subclass of a generated base class and works with typed inputs and outputs:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
from lib.Drag_base import DragBase
|
|
92
|
+
from lib.Drag_io import DragInputs, DragOutputs
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Drag(DragBase):
|
|
96
|
+
def _run(self, input_data):
|
|
97
|
+
inputs = DragInputs.from_dict(input_data)
|
|
98
|
+
duty_cycle = ... # your physics, using inputs.h, inputs.Cd, ...
|
|
99
|
+
return DragOutputs(duty_cycle=duty_cycle)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Running the generated code
|
|
103
|
+
|
|
104
|
+
`gantry` writes files. It doesn't run your analysis. The generated `execute_<Scenario>.py` and your disciplines are plain Python that import GEMSEO, so run them in a project that has GEMSEO and whatever else your physics code needs:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
uv add "gemseo>=6.3"
|
|
108
|
+
uv run execute_<Scenario>.py
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
You manage that environment yourself, and it's separate from the one `gantry` is installed in. The generated code needs GEMSEO 6.3 or later, not the exact version `gantry` happens to use.
|
|
112
|
+
|
|
113
|
+
## How it works
|
|
114
|
+
|
|
115
|
+
`gantry` has two commands that generate code, and they treat existing files in **opposite ways**:
|
|
116
|
+
|
|
117
|
+
```mermaid
|
|
118
|
+
flowchart LR
|
|
119
|
+
toml["problem.toml<br/>(source of truth)"]
|
|
120
|
+
lib["lib/<br/>(regenerated on every build)"]
|
|
121
|
+
yours["disciplines/, execute_*.py<br/>(yours, written once)"]
|
|
122
|
+
toml -->|gantry build| lib
|
|
123
|
+
toml -->|gantry scaffold| yours
|
|
124
|
+
yours -.->|imports| lib
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- **`build`** wipes and rewrites `lib/` every time. Nothing hand-written ever lives in `lib/`, so this is safe, and files left over from a rename get cleaned up.
|
|
128
|
+
- **`scaffold`** writes starter files into your tree and won't overwrite them. Once they're written, they're yours.
|
|
129
|
+
|
|
130
|
+
When the TOML changes, re-run `build`. There's no three-way merge. Anything in your code that no longer matches the problem shows up as a type or import error.
|
|
131
|
+
|
|
132
|
+
## Documentation
|
|
133
|
+
|
|
134
|
+
- [Concepts](https://github.com/axwide/gantry/blob/main/docs/concepts.md): how `build` and `scaffold` divide the work, the edit-and-rebuild loop, and what a generated project looks like.
|
|
135
|
+
- [Problem definition](https://github.com/axwide/gantry/blob/main/docs/problem-definition.md): the TOML format and how to get validation in your editor.
|
|
136
|
+
- [CLI reference](https://github.com/axwide/gantry/blob/main/docs/cli.md): every command and its options.
|
|
137
|
+
|
|
138
|
+
## Contributing
|
|
139
|
+
|
|
140
|
+
Contributions are welcome. See [CONTRIBUTING.md](https://github.com/axwide/gantry/blob/main/CONTRIBUTING.md) for the development setup and conventions.
|
|
141
|
+
|
|
142
|
+
## License
|
|
143
|
+
|
|
144
|
+
`gemseo-gantry` is released under the [MIT License](https://github.com/axwide/gantry/blob/main/LICENSE).
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# gemseo-gantry
|
|
2
|
+
|
|
3
|
+
[](https://github.com/axwide/gantry/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/gemseo-gantry/)
|
|
5
|
+
[](https://pypi.org/project/gemseo-gantry/)
|
|
6
|
+
[](https://gemseo.readthedocs.io/)
|
|
7
|
+
[](https://github.com/axwide/gantry/blob/main/LICENSE)
|
|
8
|
+
[](https://github.com/astral-sh/ruff)
|
|
9
|
+
[](https://github.com/astral-sh/uv)
|
|
10
|
+
[](https://docs.basedpyright.com/)
|
|
11
|
+
|
|
12
|
+
**Generate GEMSEO glue code for MDAO problems from a TOML problem definition.**
|
|
13
|
+
|
|
14
|
+
`gemseo-gantry` takes one diffable TOML file describing your problem and generates the GEMSEO boilerplate you'd otherwise write by hand: typed I/O dataclasses, grammars, a design space, a variables enum, discipline base classes and scenario construction. The TOML is the source of truth. When the problem changes you regenerate, and your type checker points at the hand-written code that needs updating.
|
|
15
|
+
|
|
16
|
+
> [!NOTE]
|
|
17
|
+
> `gemseo-gantry` is pre-1.0. Expect rough edges, and expect details to change between releases.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **One source of truth.** Variables, disciplines and scenarios all live in one TOML file. Variable roles such as design variable or coupling are inferred, so you don't declare them twice.
|
|
22
|
+
- **Safe regeneration.** `gantry build` rebuilds a disposable `lib/` package. `gantry scaffold` writes your discipline and executor files once and never touches them again.
|
|
23
|
+
- **The type checker does the reconciling.** Rename or split a variable and rebuild. Code of yours that no longer matches shows up as a type or import error right where it needs changing.
|
|
24
|
+
- **Fast feedback.** `gantry validate --watch` re-checks the problem every time you save. A generated JSON Schema gives you autocomplete and validation in TOML-aware editors.
|
|
25
|
+
- **Diagrams.** N2 and XDSM views of the coupling topology, drawn straight from the TOML.
|
|
26
|
+
- **Scriptable.** Every command takes `--json` for machine-readable output.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
uv tool install gemseo-gantry
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This puts the `gantry` command on your path.
|
|
35
|
+
|
|
36
|
+
## Quickstart
|
|
37
|
+
|
|
38
|
+
To see the whole pipeline, generate the Sellar example. It's a classic benchmark, and you get a complete project you can run:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
gantry example sellar # add --explain to narrate each stage
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or start your own problem:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
gantry init # 1. write a starter problem.toml (plus its JSON Schema)
|
|
48
|
+
gantry validate --watch # 2. edit problem.toml with live feedback (q/Esc to stop)
|
|
49
|
+
gantry build # 3. generate the disposable lib/ package
|
|
50
|
+
gantry scaffold # 4. write your discipline stubs and scenario executor, once
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Then fill in the physics. A scaffolded discipline is a thin subclass of a generated base class and works with typed inputs and outputs:
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from lib.Drag_base import DragBase
|
|
57
|
+
from lib.Drag_io import DragInputs, DragOutputs
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class Drag(DragBase):
|
|
61
|
+
def _run(self, input_data):
|
|
62
|
+
inputs = DragInputs.from_dict(input_data)
|
|
63
|
+
duty_cycle = ... # your physics, using inputs.h, inputs.Cd, ...
|
|
64
|
+
return DragOutputs(duty_cycle=duty_cycle)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Running the generated code
|
|
68
|
+
|
|
69
|
+
`gantry` writes files. It doesn't run your analysis. The generated `execute_<Scenario>.py` and your disciplines are plain Python that import GEMSEO, so run them in a project that has GEMSEO and whatever else your physics code needs:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
uv add "gemseo>=6.3"
|
|
73
|
+
uv run execute_<Scenario>.py
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You manage that environment yourself, and it's separate from the one `gantry` is installed in. The generated code needs GEMSEO 6.3 or later, not the exact version `gantry` happens to use.
|
|
77
|
+
|
|
78
|
+
## How it works
|
|
79
|
+
|
|
80
|
+
`gantry` has two commands that generate code, and they treat existing files in **opposite ways**:
|
|
81
|
+
|
|
82
|
+
```mermaid
|
|
83
|
+
flowchart LR
|
|
84
|
+
toml["problem.toml<br/>(source of truth)"]
|
|
85
|
+
lib["lib/<br/>(regenerated on every build)"]
|
|
86
|
+
yours["disciplines/, execute_*.py<br/>(yours, written once)"]
|
|
87
|
+
toml -->|gantry build| lib
|
|
88
|
+
toml -->|gantry scaffold| yours
|
|
89
|
+
yours -.->|imports| lib
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- **`build`** wipes and rewrites `lib/` every time. Nothing hand-written ever lives in `lib/`, so this is safe, and files left over from a rename get cleaned up.
|
|
93
|
+
- **`scaffold`** writes starter files into your tree and won't overwrite them. Once they're written, they're yours.
|
|
94
|
+
|
|
95
|
+
When the TOML changes, re-run `build`. There's no three-way merge. Anything in your code that no longer matches the problem shows up as a type or import error.
|
|
96
|
+
|
|
97
|
+
## Documentation
|
|
98
|
+
|
|
99
|
+
- [Concepts](https://github.com/axwide/gantry/blob/main/docs/concepts.md): how `build` and `scaffold` divide the work, the edit-and-rebuild loop, and what a generated project looks like.
|
|
100
|
+
- [Problem definition](https://github.com/axwide/gantry/blob/main/docs/problem-definition.md): the TOML format and how to get validation in your editor.
|
|
101
|
+
- [CLI reference](https://github.com/axwide/gantry/blob/main/docs/cli.md): every command and its options.
|
|
102
|
+
|
|
103
|
+
## Contributing
|
|
104
|
+
|
|
105
|
+
Contributions are welcome. See [CONTRIBUTING.md](https://github.com/axwide/gantry/blob/main/CONTRIBUTING.md) for the development setup and conventions.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
`gemseo-gantry` is released under the [MIT License](https://github.com/axwide/gantry/blob/main/LICENSE).
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "gemseo-gantry"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Generate GEMSEO glue code for MDAO problems from a TOML problem definition."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
keywords = [
|
|
10
|
+
"gemseo",
|
|
11
|
+
"mdao",
|
|
12
|
+
"mdo",
|
|
13
|
+
"optimization",
|
|
14
|
+
"code-generation",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Science/Research",
|
|
19
|
+
"Topic :: Scientific/Engineering",
|
|
20
|
+
"Topic :: Software Development :: Code Generators",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"jinja2>=3.1.6",
|
|
29
|
+
"lazy-loader>=0.4",
|
|
30
|
+
"pandas>=2.3.2",
|
|
31
|
+
"pydantic>=2.11.9",
|
|
32
|
+
"python-slugify>=8.0.4",
|
|
33
|
+
"black>=25.1.0",
|
|
34
|
+
"isort>=6.0.1",
|
|
35
|
+
"gemseo[all]>=6.3.0,<7",
|
|
36
|
+
"typer>=0.15.0",
|
|
37
|
+
"rich>=13.0.0",
|
|
38
|
+
"watchfiles>=0.21",
|
|
39
|
+
"readchar>=4.2.2",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[[project.authors]]
|
|
43
|
+
name = "Axel Widenfelt"
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/axwide/gantry"
|
|
47
|
+
Documentation = "https://github.com/axwide/gantry/tree/main/docs"
|
|
48
|
+
Issues = "https://github.com/axwide/gantry/issues"
|
|
49
|
+
|
|
50
|
+
[project.scripts]
|
|
51
|
+
gantry = "gemseo_gantry.cli.main:app"
|
|
52
|
+
|
|
53
|
+
[dependency-groups]
|
|
54
|
+
dev = [
|
|
55
|
+
"ipykernel>=7.1.0",
|
|
56
|
+
"jsonschema>=4.23",
|
|
57
|
+
"prek>=0.4",
|
|
58
|
+
"pytest>=9.0.1",
|
|
59
|
+
"pytest-cov>=7.0.0",
|
|
60
|
+
"ruff>=0.14.7",
|
|
61
|
+
"debugpy>=1.8.17",
|
|
62
|
+
"basedpyright>=1.20.0",
|
|
63
|
+
"syrupy>=4",
|
|
64
|
+
]
|
|
65
|
+
|
|
66
|
+
[build-system]
|
|
67
|
+
requires = ["uv_build>=0.9.15,<0.10.0"]
|
|
68
|
+
build-backend = "uv_build"
|
|
69
|
+
|
|
70
|
+
[tool.pytest.ini_options]
|
|
71
|
+
addopts = [
|
|
72
|
+
"--snapshot-warn-unused",
|
|
73
|
+
"--import-mode=importlib",
|
|
74
|
+
"--cov=src/gemseo_gantry",
|
|
75
|
+
"--cov-fail-under=90",
|
|
76
|
+
]
|
|
77
|
+
filterwarnings = [
|
|
78
|
+
"ignore::DeprecationWarning",
|
|
79
|
+
"ignore::SyntaxWarning:pyDOE3.doe_korobov",
|
|
80
|
+
]
|
|
81
|
+
pythonpath = ["src"]
|
|
82
|
+
markers = ["slow: marks tests as slow (run in full CI but not in quick unit check)"]
|
|
83
|
+
|
|
84
|
+
[tool.coverage.run]
|
|
85
|
+
source = ["src/gemseo_gantry"]
|
|
86
|
+
omit = [
|
|
87
|
+
"src/gemseo_gantry/generator/templates/*",
|
|
88
|
+
"src/gemseo_gantry/examples/*/disciplines/*",
|
|
89
|
+
"src/gemseo_gantry/examples/*/scenarios/*",
|
|
90
|
+
"src/gemseo_gantry/examples/*/postprocess.py",
|
|
91
|
+
"src/gemseo_gantry/examples/*/execute_*.py",
|
|
92
|
+
]
|
|
93
|
+
|
|
94
|
+
[tool.coverage.report]
|
|
95
|
+
exclude_lines = [
|
|
96
|
+
"pragma: no cover",
|
|
97
|
+
"if TYPE_CHECKING:",
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[tool.ruff.lint]
|
|
101
|
+
extend-select = [
|
|
102
|
+
"RUF001",
|
|
103
|
+
"RUF002",
|
|
104
|
+
"RUF003",
|
|
105
|
+
]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "gemseo-gantry"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Generate GEMSEO glue code for MDAO problems from a TOML problem definition."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Axel Widenfelt" }]
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
keywords = ["gemseo", "mdao", "mdo", "optimization", "code-generation"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"Intended Audience :: Science/Research",
|
|
14
|
+
"Topic :: Scientific/Engineering",
|
|
15
|
+
"Topic :: Software Development :: Code Generators",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
"Programming Language :: Python :: 3.13",
|
|
21
|
+
]
|
|
22
|
+
dependencies = [
|
|
23
|
+
"jinja2>=3.1.6",
|
|
24
|
+
"lazy-loader>=0.4",
|
|
25
|
+
"pandas>=2.3.2",
|
|
26
|
+
"pydantic>=2.11.9",
|
|
27
|
+
"python-slugify>=8.0.4",
|
|
28
|
+
"black>=25.1.0",
|
|
29
|
+
"isort>=6.0.1",
|
|
30
|
+
"gemseo[all]>=6.3.0,<7",
|
|
31
|
+
"typer>=0.15.0",
|
|
32
|
+
"rich>=13.0.0",
|
|
33
|
+
"watchfiles>=0.21",
|
|
34
|
+
"readchar>=4.2.2",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://github.com/axwide/gantry"
|
|
39
|
+
Documentation = "https://github.com/axwide/gantry/tree/main/docs"
|
|
40
|
+
Issues = "https://github.com/axwide/gantry/issues"
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
gantry = "gemseo_gantry.cli.main:app"
|
|
44
|
+
|
|
45
|
+
[dependency-groups]
|
|
46
|
+
dev = [
|
|
47
|
+
"ipykernel>=7.1.0",
|
|
48
|
+
"jsonschema>=4.23",
|
|
49
|
+
"prek>=0.4",
|
|
50
|
+
"pytest>=9.0.1",
|
|
51
|
+
"pytest-cov>=7.0.0",
|
|
52
|
+
"ruff>=0.14.7",
|
|
53
|
+
"debugpy>=1.8.17",
|
|
54
|
+
"basedpyright>=1.20.0",
|
|
55
|
+
"syrupy>=4",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[build-system]
|
|
59
|
+
requires = ["uv_build>=0.9.15,<0.10.0"]
|
|
60
|
+
build-backend = "uv_build"
|
|
61
|
+
|
|
62
|
+
[tool.pytest.ini_options]
|
|
63
|
+
addopts = ["--snapshot-warn-unused", "--import-mode=importlib", "--cov=src/gemseo_gantry", "--cov-fail-under=90"]
|
|
64
|
+
filterwarnings = [
|
|
65
|
+
"ignore::DeprecationWarning",
|
|
66
|
+
"ignore::SyntaxWarning:pyDOE3.doe_korobov",
|
|
67
|
+
]
|
|
68
|
+
pythonpath = ["src"]
|
|
69
|
+
markers = [
|
|
70
|
+
"slow: marks tests as slow (run in full CI but not in quick unit check)",
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
[tool.coverage.run]
|
|
74
|
+
source = ["src/gemseo_gantry"]
|
|
75
|
+
omit = [
|
|
76
|
+
"src/gemseo_gantry/generator/templates/*",
|
|
77
|
+
"src/gemseo_gantry/examples/*/disciplines/*",
|
|
78
|
+
"src/gemseo_gantry/examples/*/scenarios/*",
|
|
79
|
+
"src/gemseo_gantry/examples/*/postprocess.py",
|
|
80
|
+
"src/gemseo_gantry/examples/*/execute_*.py",
|
|
81
|
+
]
|
|
82
|
+
|
|
83
|
+
[tool.coverage.report]
|
|
84
|
+
exclude_lines = [
|
|
85
|
+
"pragma: no cover",
|
|
86
|
+
"if TYPE_CHECKING:",
|
|
87
|
+
]
|
|
88
|
+
|
|
89
|
+
[tool.ruff.lint]
|
|
90
|
+
# Flag Unicode characters easily confused with ASCII (en dash, minus sign, ...).
|
|
91
|
+
extend-select = ["RUF001", "RUF002", "RUF003"]
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
if TYPE_CHECKING:
|
|
6
|
+
from gemseo_gantry.diagram import generate_n2, generate_xdsm
|
|
7
|
+
from gemseo_gantry.generator import (
|
|
8
|
+
ALL_ARTIFACTS,
|
|
9
|
+
generate_lib,
|
|
10
|
+
generate_scaffold,
|
|
11
|
+
)
|
|
12
|
+
from gemseo_gantry.model.data_model import ProblemDefinition
|
|
13
|
+
from gemseo_gantry.validation import validate_toml
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"ALL_ARTIFACTS",
|
|
17
|
+
"ProblemDefinition",
|
|
18
|
+
"validate_toml",
|
|
19
|
+
"generate_lib",
|
|
20
|
+
"generate_scaffold",
|
|
21
|
+
"generate_n2",
|
|
22
|
+
"generate_xdsm",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
_lazy: dict[str, str] = {
|
|
26
|
+
"ALL_ARTIFACTS": "gemseo_gantry.generator",
|
|
27
|
+
"generate_n2": "gemseo_gantry.diagram",
|
|
28
|
+
"generate_xdsm": "gemseo_gantry.diagram",
|
|
29
|
+
"generate_lib": "gemseo_gantry.generator",
|
|
30
|
+
"generate_scaffold": "gemseo_gantry.generator",
|
|
31
|
+
"ProblemDefinition": "gemseo_gantry.model.data_model",
|
|
32
|
+
"validate_toml": "gemseo_gantry.validation",
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def __getattr__(name: str) -> object:
|
|
37
|
+
if name not in _lazy:
|
|
38
|
+
raise AttributeError(f"module 'gemseo_gantry' has no attribute {name!r}")
|
|
39
|
+
import importlib
|
|
40
|
+
|
|
41
|
+
mod = importlib.import_module(_lazy[name])
|
|
42
|
+
obj = getattr(mod, name)
|
|
43
|
+
globals()[name] = obj
|
|
44
|
+
return obj
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from enum import StrEnum
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class ArtifactKind(StrEnum):
|
|
9
|
+
DISCIPLINE_BASE = "discipline_base"
|
|
10
|
+
DISCIPLINE_GRAMMAR = "discipline_grammar"
|
|
11
|
+
DISCIPLINE_IO = "discipline_io"
|
|
12
|
+
DISCIPLINE_SCAFFOLD = "discipline_scaffold"
|
|
13
|
+
SCENARIO = "scenario"
|
|
14
|
+
EXECUTOR = "executor"
|
|
15
|
+
VARIABLES = "variables"
|
|
16
|
+
DESIGN_SPACE = "design_space"
|
|
17
|
+
PACKAGE_INIT = "package_init"
|
|
18
|
+
DIAGRAM = "diagram"
|
|
19
|
+
PROBLEM_DEFINITION = "problem_definition"
|
|
20
|
+
SCHEMA = "schema"
|
|
21
|
+
EXAMPLE = "example"
|
|
22
|
+
DISCIPLINE = "discipline"
|
|
23
|
+
POSTPROCESSOR = "postprocessor"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class ArtifactStatus(StrEnum):
|
|
27
|
+
WRITTEN = "written"
|
|
28
|
+
SKIPPED = "skipped"
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class GeneratedArtifact:
|
|
33
|
+
path: Path
|
|
34
|
+
kind: ArtifactKind
|
|
35
|
+
status: ArtifactStatus = ArtifactStatus.WRITTEN
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def rel_to_cwd(path: Path) -> str:
|
|
7
|
+
"""Path relative to CWD when possible, else unchanged; always POSIX slashes."""
|
|
8
|
+
try:
|
|
9
|
+
return path.resolve().relative_to(Path.cwd().resolve()).as_posix()
|
|
10
|
+
except ValueError:
|
|
11
|
+
return path.as_posix()
|