Skip to main content

Python SDK for rototo runtime configuration workspaces.

Project description

rototo Python SDK

The Python SDK is a thin native wrapper around the Rust SDK. Python code gets an idiomatic async API while rototo keeps workspace loading, linting, refresh, and resolution behavior in the Rust core.

Install

The package is built with maturin while rototo is in alpha:

cd sdks/python
python -m maturin develop

After release, install the published package:

python -m pip install rototo

The rototo release version stays SemVer, for example 0.1.0-alpha.3. Python packaging tools may display the equivalent PEP 440 spelling 0.1.0a3 for the distribution.

Load A Workspace

import rototo

workspace = await rototo.Workspace.load("examples/basic")

Workspace.load accepts the same source strings as the CLI. It lints the workspace and rejects lint failures before returning.

Resolve A Variable

resolution = await workspace.resolve_variable(
    "premium-message",
    {"user": {"tier": "premium"}},
)

print(resolution.value_key)
print(resolution.value)

VariableResolution has:

Field Meaning
id Variable id.
value_key Selected value key.
value Selected JSON-compatible Python value.

Resolve A Qualifier

resolution = await workspace.resolve_qualifier(
    "premium-users",
    {"user": {"tier": "premium"}},
)

print(resolution.value)

QualifierResolution has id and value.

Context Validation

Resolution validates context against schemas/context.schema.json by default. Skip validation for one call when a tool needs to evaluate partial context:

resolution = await workspace.resolve_variable(
    "premium-message",
    context,
    validate_context=False,
)

The context still must be a JSON object.

Inspect And Lint

workspace = await rototo.Workspace.inspect("examples/basic")
lint = await workspace.lint()

Inspection is for tools. A workspace loaded through inspect cannot resolve variables or qualifiers because it does not compile the runtime model.

Refreshing Workspace

workspace = await rototo.RefreshingWorkspace.load(
    source,
    period_seconds=30,
)

resolution = await workspace.resolve_variable("premium-message", context)
status = await workspace.status()
await workspace.shutdown()

RefreshingWorkspace keeps serving the last successfully loaded workspace when refresh fails. status returns a RefreshStatus dataclass with fingerprint, success, attempt, failure, error, refreshing, and immutable fields.

Errors

Rust RototoError values become rototo.RototoError in Python:

try:
    await workspace.resolve_variable("missing", {})
except rototo.RototoError as error:
    print(error)

Invalid Python option values, such as an unknown lint mode, raise Python ValueError.

Public Types

Type Purpose
Workspace Loaded workspace handle.
RefreshingWorkspace Refreshing workspace handle for services.
VariableResolution Selected variable value.
QualifierResolution Qualifier boolean result.
RefreshStatus Refresh state snapshot.
RototoError Error raised for rototo failures.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rototo-0.1.0a4.tar.gz (285.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

rototo-0.1.0a4-cp310-abi3-win_amd64.whl (4.4 MB view details)

Uploaded CPython 3.10+Windows x86-64

rototo-0.1.0a4-cp310-abi3-manylinux_2_28_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

rototo-0.1.0a4-cp310-abi3-manylinux_2_28_aarch64.whl (5.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

rototo-0.1.0a4-cp310-abi3-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

rototo-0.1.0a4-cp310-abi3-macosx_10_12_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file rototo-0.1.0a4.tar.gz.

File metadata

  • Download URL: rototo-0.1.0a4.tar.gz
  • Upload date:
  • Size: 285.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rototo-0.1.0a4.tar.gz
Algorithm Hash digest
SHA256 7d3f140bf0eb6e603644ffec1b3ab2eb1a39450118236a93e29af9bebc27cd34
MD5 6306a26b770bc1aeca9a9af2cfb1b3b1
BLAKE2b-256 faa0360d5b2c7a291055196ed2c5e3baeeabc3dc88b27d6c04585eb52de9957b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rototo-0.1.0a4.tar.gz:

Publisher: release.yml on manasgarg/rototo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rototo-0.1.0a4-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: rototo-0.1.0a4-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for rototo-0.1.0a4-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 856548072ac8f604633b07db828f6f10fc6b0b5d6d0f52b22e822b8ccd7fbeb0
MD5 6d0d7ed91f120187e7a4efe0163423ff
BLAKE2b-256 6dfb2d89f38c229ccbce9b0843e1351e8c88abad09f6f212496f869f69fc3c98

See more details on using hashes here.

Provenance

The following attestation bundles were made for rototo-0.1.0a4-cp310-abi3-win_amd64.whl:

Publisher: release.yml on manasgarg/rototo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rototo-0.1.0a4-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for rototo-0.1.0a4-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 85772ef8c4955bce9f369774c0bcf36aec908f3339049bedceb330ff34da1a80
MD5 c9c3bfe2b75e9a03b9e19ee97dc864b5
BLAKE2b-256 75634c7751fd1442dc1584aee1feecf978f12b0790cfa37ce55a1429f83edde8

See more details on using hashes here.

Provenance

The following attestation bundles were made for rototo-0.1.0a4-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: release.yml on manasgarg/rototo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rototo-0.1.0a4-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for rototo-0.1.0a4-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 68b441e0e448941ba3932a33e4067d9b11ac11cfcee034e57f0ac517d8d875f7
MD5 a18d531af16959f7284b694b82eac86e
BLAKE2b-256 fe962da8eb66e03eb9a462ac4f964f2dd25df299c94182c5a8470b3439d68f73

See more details on using hashes here.

Provenance

The following attestation bundles were made for rototo-0.1.0a4-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: release.yml on manasgarg/rototo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rototo-0.1.0a4-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rototo-0.1.0a4-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6d0e3aefe50fd412602e6ffaa82bec783cd92d412c973b730b5b17b61d5880bd
MD5 93ca5c14b8e469809a067c79aea28499
BLAKE2b-256 986bfee40d80df8477c26e4dd43378e3ea626d46800996c02a6da8874b68671f

See more details on using hashes here.

Provenance

The following attestation bundles were made for rototo-0.1.0a4-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on manasgarg/rototo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rototo-0.1.0a4-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for rototo-0.1.0a4-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 9a09121ca44779811cd436d83ad24f5e5dab9233349523c5237d01b83d69ae55
MD5 1c6d7b09e2998e38b79a4c78a39bfec9
BLAKE2b-256 d87cb34410f06c62d6859e2a5b0c95f5f94f83d7d177bf1332d6fd81c17caf90

See more details on using hashes here.

Provenance

The following attestation bundles were made for rototo-0.1.0a4-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release.yml on manasgarg/rototo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page