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.1

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.1
File Size Uploaded Provenance Actions
bonsai_sgen-0.11.1.tar.gz 40.1 kB Without provenance Details for bonsai_sgen-0.11.1.tar.gz

Built distribution (wheel)

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

Total release size: 59.7 kB

Release files / bonsai_sgen-0.11.1.tar.gz

Download URL bonsai_sgen-0.11.1.tar.gz
Size 40.1 kB
Tags Source
SHA-256 checksum
How to use checksums
30ea38807a28f3cac5f89171ddfe21a75a8e3a8decc3a2794367ddc92f86e138
BLAKE2b-256 checksum
How to use checksums
b36b078f69e67ce05d4fe6518caf84503cc31d3fd6e2794a8c1edfd4d3b6aa0e
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.1-py3-none-any.whl

Download URL bonsai_sgen-0.11.1-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d11b03f191e41c1be8656f9ace57371d4eb0f39d9dd32bfa667dbccf7528f4d5
BLAKE2b-256 checksum
How to use checksums
ff43a1c5d521db6a1805ffed4f1c9fd7cab79ecb9339b5143ebc157fbbe6af0e
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.1

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