You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Adding a script to generate pydantic class from GEOS XSD schema.
* Get the schema from github REST/API
* Fix hard coded variable
* Discard all but ProblemType
* Regen schema
* Update ReadMe
---------
Co-authored-by: jacques franc <jacquesfrancdev@gmail.com>
Copy file name to clipboardExpand all lines: geos-trame/src/geos/trame/schema_generated/README.md
+37-29Lines changed: 37 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,49 +11,57 @@ to parse, serialize and deserialize these files in trame with `trame-simput`, we
11
11
generate a serializable class for each balise described in the schema used by GEOS.
12
12
13
13
For that we use a python module named `xsd-pydantic` which allows us to generate a file.
14
-
It will contain all class for a given xsd schema file.
14
+
It will contain all class for a given xsd schema file.
15
15
16
16
When starting the trame application, we can instantiate the expected dataclass when parsing
17
17
the input file.
18
18
19
19
## How to generate a new file
20
20
21
-
#### 1. Clone the GEOS Repository
21
+
First, retrieve the `schema.xsd` corresponding to the GEOS version you want to use.
22
22
23
-
```bash
24
-
git clone git@github.com:GEOS-DEV/GEOS.git
25
-
```
23
+
> [!WARNING]
24
+
> We advise to use GEOS version from commit [#1e617be](https://github.com/GEOS-DEV/GEOS/commit/1e617be8614817d92f0a7a159994cbed1661ff98). You may encounter compatibility issues with older versions.
26
25
27
-
#### 2. Create a dedicate venv
26
+
In a sourced virtual environement set for geos_trame,
28
27
29
28
```bash
30
-
cd<path-to-geos-trame>
31
-
python -m venv pydantic-venv
32
-
source pydantic-venv/bin/activate
33
-
pip install -e .
34
-
pip install "xsdata[cli]"
35
-
cd src/geos_trame/schema_generated
29
+
(venv) cd geosPythonPackages/geos-trame/src/geos/trame/schema_generated
1. To take the latest commit on GEOS' `develop`. However, if a particular commit on `develop` is of interest,
38
+
you can pass it through the option `-c <GEOS-commit-sha>`. It will generate `schema_<GEOS-commit-sha>.xsd`.
39
+
2. To generate the `schema_mod.py` packages, metadata-ing the commit number in the header.
45
40
46
-
Then update the generated file, at the beginning, by adding the geos commit used:
41
+
In any other case, `schema.xsd` can be found in [GEOS Github repository](https://github.com/GEOS-DEV/GEOS) under `GEOS/src/coreComponents/schema/schema.xsd`
42
+
and the first step can be skipped.
47
43
48
-
For example:
44
+
The second stage relies on `xsdata[cli]` interfaced with `pydantic` as driver.
45
+
The full documentation can be found [here](https://xsdata-pydantic.readthedocs.io/en/latest/codegen/).
49
46
50
-
```py
51
-
"""This file was generated by xsdata, v24.6.1, on 2024-11-29
52
-
53
-
Generator: PydanticGenerator
54
-
See: https://xsdata.readthedocs.io/
55
-
56
-
GEOS commit hash: <add-the-commit-hash-here>
57
-
"""
58
-
```
47
+
Options to the helper script can be displayed with `--help` parameters:
0 commit comments