python-from-jse is a generic JSON-spec-to-Python generator.
It reads a JSON schema-like spec and emits:
generated/generated_class.py: Python configuration classes that follow the schemagenerated/generated_api.py: factory functions for building configurationsgenerated/*_manifest.json: manifests used by validators and optional project integrationsgenerated/schema_patch_report.json: applied schema patch diagnostics
This repository contains the generator, generic examples, validators, and tests. Keep project-specific schemas and API settings in the project that uses it.
Install the generator from this repository:
python -m pip install -e .
python-from-jse-generate --helpRun the default generic example from this directory:
python tools\regenerate_and_test.pyThis command:
- reads
examples/basic_generation/input-spec.json; - applies
examples/basic_generation/generator_overrides.json; - writes generated artifacts under
generated/; - compiles the generated Python files;
- runs the generator unit test suite.
For a custom schema:
python-from-jse-generate `
--schema-file path\to\input-spec.json `
--include-spec-dir path\to\linked-specs `
--overrides path\to\generator_overrides.json `
--output-file generated\generated_class.py `
--api-output-file generated\generated_api.py `
--manifest-dir generated--overrides is optional. If omitted, the generator uses the schema directly.
--include-spec-dir is also optional and is only needed when the input spec
references include files that live outside the schema file's directory.
Run the full standalone check from this repository root:
python tools/regenerate_and_test.pyThis is the same command used by CI. It regenerates the generic example
artifacts under generated/, compiles generator/JsonToTreeClass.py and the
generated Python files, then runs:
python -m unittest discover -s testsSome optional full-spec smoke tests are skipped unless PolyFEM's full schema and
linked solver specs are available. Those skips are expected for standalone CI;
the generator's default standalone workflow uses only examples/basic_generation/.
See tests/README.md for test groups and optional full-spec checks.
The GitHub Actions workflow at .github/workflows/ci.yml runs on Ubuntu,
macOS, and Windows with Python 3.10, 3.11, and 3.12. Each job installs the
package, checks the console command, and runs the standalone check above.
A successful run covers the bundled generic example without a consuming project
checkout. Project-specific schema and API checks belong in the consuming project.
An editable installation does not verify the contents of a release wheel.
Some projects need extra config around the generated API. These inputs are optional and are only used when passed explicitly:
python tools\generate_with_overrides.py `
--schema-file path\to\input-spec.json `
--api-aliases path\to\api_aliases.json `
--relationships path\to\id_relationships.jsonThe supported example shapes live in:
examples/config_capabilities/api_aliases.example.jsonexamples/config_capabilities/schema_patches.example.jsonexamples/config_capabilities/id_relationships.example.json
Validator modules can be run directly after generating manifests:
python -m validators.api_aliases
python -m validators.id_relationshipsBy default these validators use the generic example config and generated/
manifests. Consuming projects should pass their own config and manifest paths.
Generated files are build artifacts. Do not edit them by hand:
generated/generated_class.pygenerated/generated_api.pygenerated/*_manifest.jsongenerated/schema_patch_report.json
If generated output is wrong, update the input spec, overrides, config examples, or generator logic, then regenerate.
See tools/README.md for input paths and command options.
Consuming projects should keep their schema files, package output paths, and public API policy outside this generator repo. The usual pattern is:
- keep the real schema in the backend or project repo that owns it;
- keep project-specific overrides/config in the consuming project;
- add a small project wrapper that calls
tools/generate_with_overrides.pywith explicit paths; - run project-specific generated API checks in the consuming project;
- document those project paths in the consuming project.
The generator repo only needs the dummy/example schema under
examples/basic_generation/ so its own tests can run without any consuming
project checkout.
examples/ Generic runnable examples and dummy config capability examples.
generator/ Generator core and generic helper code.
tools/ Generation and verification workflow CLI entry points.
validators/ Reusable validation logic imported by tools and tests.
tests/ Generator, generated API, builder, and validator tests.
This project is available under the MIT License.