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) -> CheckReportvalidate(paths=None, recursive=False, cwd=None) -> ListReportlist_budgets(paths=None, ids=None, labels=None, exclude_labels=None, recursive=False, cwd=None) -> ListReportschema() -> 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.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| onebudgetspec_sdk-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Release files / onebudgetspec_sdk-0.1.2-py3-none-any.whl
| Download URL | onebudgetspec_sdk-0.1.2-py3-none-any.whl |
|---|---|
| Size | 12.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd40b40cd2afa755fcd452ae663bb72fd285336694fb74464486e39290baba19
|
|
BLAKE2b-256 checksum How to use checksums |
4360ebdff7aa1abae8cc653f1c0c4a416e0136d9d5a3ca309c3a19dee593d2e8
|
| 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}
|