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.10.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.10.0
File Size Uploaded Provenance
bonsai_sgen-0.10.0.tar.gz 35.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 52.8 kB

Release files / bonsai_sgen-0.10.0.tar.gz

Download URL bonsai_sgen-0.10.0.tar.gz
Size 35.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a52b768f01c5a7497a360ad6d320791a7ebfaaa8482698fde1a05f2d54b0f3cd
BLAKE2b-256 checksum
How to use checksums
b432dab2290d58788908f65843c991b267d32fa6d335dce8057ad0a5542167e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","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.0-py3-none-any.whl

Download URL bonsai_sgen-0.10.0-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6822331ae57faeaa49b6be0e905cadee994a170e062f757fb33b566433851de6
BLAKE2b-256 checksum
How to use checksums
157df260f5fe8ef38bd700bbc45d228aa076bf87590a2ad3c488dc1e4edf4cfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.4 {"installer":{"name":"uv","version":"0.13.4","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}

Security for bonsai-sgen 0.10.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.

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