Skip to main content

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

  1. Install the package:

    pip install bonsai-sgen
    
  2. 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
    
  3. Write the schema of the models to a file named after the namespace:

    bonsai-sgen export person_and_discriminated_pets -o schemas
    
  4. Generate the C# types with the release of Bonsai.Sgen matching the installed version of bonsai-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.11.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bonsai-sgen 0.11.0
File Size Uploaded Provenance Actions
bonsai_sgen-0.11.0.tar.gz 39.4 kB Without provenance Details for bonsai_sgen-0.11.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bonsai-sgen 0.11.0
File Interpreter ABI Platform Actions
bonsai_sgen-0.11.0-py3-none-any.whl Python 3 none any Details for bonsai_sgen-0.11.0-py3-none-any.whl

Total release size: 58.9 kB

Release files / bonsai_sgen-0.11.0.tar.gz

Download URL bonsai_sgen-0.11.0.tar.gz
Size 39.4 kB
Tags Source
SHA-256 checksum
How to use checksums
04c7e9ce7169e8f423f91197fa5d7e59d9603f03865166f07495c46a169965a1
BLAKE2b-256 checksum
How to use checksums
4265e60e73c8c2e0d7b4586bf2c4c4419ded72f4c0e9470f59fd345a886dc29d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","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.11.0-py3-none-any.whl

Download URL bonsai_sgen-0.11.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8706004938dd7540fede0caa108c64aece73d0251d5fdb16fcd9ca84a8a7af00
BLAKE2b-256 checksum
How to use checksums
60286a87a3f1f61cb6024b3eb2fb8a5feb408d89978a08fa89fd75d85d2187f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for bonsai-sgen 0.11.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page