Skip to main content

onebudgetspec-sdk

The Python SDK for onebudgetspec, imported as onebudgetspec_sdk. It releases at the same version as the onebudgetspec command line and requires onebudgetspec-cli at that version, whose wheel installs the binary.

pip install onebudgetspec-sdk

Each call runs the onebudgetspec binary once, validates the JSON report it prints against onebudgetspec schema, and returns it as a pydantic model generated from that schema:

from onebudgetspec_sdk import check, list_budgets, schema, validate

report = check(
    paths=None, ids=None, labels=["api"], exclude_labels=["slow"], recursive=False, cwd="."
)
for result in report.results:
    print(result.id, result.verdict, result.actual, result.threshold, result.headroom)
    print(result.host.conditions)  # declared conditions, and any the command returned

listed = list_budgets(labels=["api"])  # ListReport; runs no command
validated = validate(recursive=True, paths=["."])  # ListReport of every budget; runs no command
bundle = schema()  # the JSON Schema bundle, as a dict
  • check(paths=None, ids=None, labels=None, exclude_labels=None, recursive=False, cwd=None) -> CheckReport
  • validate(paths=None, recursive=False, cwd=None) -> ListReport
  • list_budgets(paths=None, ids=None, labels=None, exclude_labels=None, recursive=False, cwd=None) -> ListReport
  • schema() -> dict

Exit statuses 0 (within), 1 (over) and 3 (a measurement errored) all return the report, since the verdicts are in it. Status 2, an invalid invocation or budgets file, raises OnebudgetspecError with the CLI's own message and exit_code == 2.

The binary is, in order: the binary= keyword every call takes, then ONEBUDGETSPEC_BIN, then the onebudgetspec the onebudgetspec-cli wheel installed, then onebudgetspec on PATH. resolve_binary() says which.

The models are generated by generate.py from the binary's own schema. In the repository, just generate regenerates them and just lint fails while they and the schema part.

Metadata

Release files for onebudgetspec-sdk 0.1.0

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

Built distribution (wheel)

Table of built distributions (wheels) for onebudgetspec-sdk 0.1.0
File Interpreter ABI Platform
onebudgetspec_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Release files / onebudgetspec_sdk-0.1.0-py3-none-any.whl

Download URL onebudgetspec_sdk-0.1.0-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4103dcfb36bf781f10cb04cbef6f19ed1b186331e6e32644049d2caa142c39fe
BLAKE2b-256 checksum
How to use checksums
52a6cdf33b3601327fd9b1efe448fb86749cbaa5965ca06826f627d75c972fc5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.23 {"installer":{"name":"uv","version":"0.12.23","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 history Release notifications | RSS feed

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

This release

0.1.0 This release

1 release file

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