This release is a pre-release and may not be stable for production use.
bonsai-sgen
bonsai-sgen provides pydantic base classes for data types shared with the Bonsai visual reactive programming language. Models derived from these classes export JSON schemas from which Bonsai.Sgen generates matching C# types and serialization operators.
Each release of bonsai-sgen matches the release of Bonsai.Sgen with the same version number, and exports schemas following the conventions of that release.
How to Use
-
Install the package:
pip install bonsai-sgen
-
Define the models in a module,
person_and_discriminated_pets.py, that declares the namespace of the generated types:from abc import ABC from typing import Annotated, Literal from pydantic import Field from typing_extensions import TypeAliasType from bonsai.sgen import SchemaModel SGEN_NAMESPACE = "PersonAndDiscriminatedPets" class PetBase(SchemaModel, ABC): age: int | None = None class Cat(PetBase): pet_type: Literal["cat"] = "cat" can_meow: bool = True class Dog(PetBase): pet_type: Literal["dog"] = "dog" can_bark: bool | None = True Pet = TypeAliasType("Pet", Annotated[Cat | Dog, Field(discriminator="pet_type")]) class PersonAndPet(SchemaModel): owner: str pet: Pet | None = None
-
Write the schema of the models to a file named after the namespace:
bonsai-sgen export person_and_discriminated_pets -o schemas
-
Generate the C# types with the release of
Bonsai.Sgenmatching the installed version ofbonsai-sgen:dotnet bonsai.sgen schemas/PersonAndDiscriminatedPets.json -o Extensions --serializer json yaml
Additional Documentation
For additional documentation and examples, refer to the official Bonsai.Sgen documentation.
Feedback & Contributing
bonsai-sgen is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Metadata
Release files for bonsai-sgen 0.10.0rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bonsai_sgen-0.10.0rc1.tar.gz | 27.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bonsai_sgen-0.10.0rc1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.3 kB
Release files / bonsai_sgen-0.10.0rc1.tar.gz
| Download URL | bonsai_sgen-0.10.0rc1.tar.gz |
|---|---|
| Size | 27.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cdcb237e2d8c1124170f92c56f87002a7f381ac848f8537dd54f11738674a9f
|
|
BLAKE2b-256 checksum How to use checksums |
01372660a60143a8e5010a38b083060dc02f18da8778b987c56888dbcd7e80b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / bonsai_sgen-0.10.0rc1-py3-none-any.whl
| Download URL | bonsai_sgen-0.10.0rc1-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4de9b0350f4d92f5d1fad09d36ca663aaa9be4eab9ced99da664b03746fd50b6
|
|
BLAKE2b-256 checksum How to use checksums |
33946c1181a2d39c5f2477d9dba587f13534b83f63eecae306ffebeb3615e122
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|