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

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.5
File Interpreter ABI Platform Actions
onebudgetspec_sdk-0.1.5-py3-none-any.whl Python 3 none any Details for onebudgetspec_sdk-0.1.5-py3-none-any.whl

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

Download URL onebudgetspec_sdk-0.1.5-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c2bd0535d20d72418f1dae3a1a5ed6d18537f2084beefac7021b961a0dede00e
BLAKE2b-256 checksum
How to use checksums
f5fdae7662dbd55a6370a1b564810e66b94b64bf8dc4f375cc077d1776601db6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","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 onebudgetspec-sdk 0.1.5

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