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
  • report(value: float, detail: str | None = None) -> bool, which runs no binary: a reported budget's command calls it to write its result to the file ONEBUDGETSPEC_RESULT names, replacing it, and gets True. With that variable unset or empty it writes nothing and returns False, so a test that measures behaves the same outside a check. A non-finite value raises ValueError and a failed write OSError, and neither writes anything. It never reads a budgets file or judges the value; onebudgetspec check does. Every budget's command also gets its id in ONEBUDGETSPEC_BUDGET_ID.

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

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.4
File Interpreter ABI Platform
onebudgetspec_sdk-0.1.4-py3-none-any.whl Python 3 none any Details

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

Download URL onebudgetspec_sdk-0.1.4-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2856910af760ae9698db32211f48b7f239f9fc8418958d7604f43b47fa1e2b7
BLAKE2b-256 checksum
How to use checksums
d12f897cce5f43faf431dd8c1c93765b63fd127def5d6c8d69624f9945158d5a
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

This release

0.1.4 This release

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

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