ocracy.status#
Backend readiness status — four nested levels, info dicts, and a Markdown table.
ocracy describes far more OCR engines than any one machine has ready to run, so it helps to know, at a glance, where each one stands. Four nested levels:
all — every engine in the ledger (
ocracy/data/backends.json).implemented — ocracy ships a working facade for it (
⊆ all).set_up — ready to run here, now: the engine/client library is importable and, for a remote backend, its credential env var is present (
⊆ implemented).tested — actually produced text from a small image on this machine (
⊆ set_up).
all ⊇ implemented ⊇ set_up ⊇ tested.
API:
backend_ids()— the id list at a level.backend_info()—{id: {...all ledger fields..., implemented, set_up, tested}}.status_table()— an aligned Markdown table (also readable as plain text).names_with_sites()—"Name (website), ..."for a set of ids.
Note
computing tested runs real OCR — for remote backends that means a real
(possibly billed) API call. Use the run_tests argument to control exactly which
backends get called.
Functions
|
Ready to run here & now. |
|
Actually run OCR on |
|
Sorted backend ids at a readiness |
|
Per-backend status: every ledger field plus |
|
Render an aligned Markdown table of backend status (also plain-text readable). |
|
|
- ocracy.status.backend_ids(level='all', *, info=None, test_image=None)[source]#
Sorted backend ids at a readiness
level(one ofLEVELS).Pass a precomputed
info(frombackend_info()) to avoid recomputation — important for"tested", which otherwise re-runs OCR.
- ocracy.status.backend_info(ids=None, *, run_tests=False, test_image=None)[source]#
Per-backend status: every ledger field plus
implemented/set_up/tested.- Parameters:
ids (
Optional[Iterable[str]]) – Which backends (default: every ledger id).run_tests – Which set-up backends to actually OCR-test.
True= all set-up (real API calls for remotes!);False= none (testedisNone); or an iterable of ids to limit testing to those.test_image (
Any) – Image to test with (default: a generated one, shared across all).
- Return type:
- Returns:
{id: {..., "name", "website", "implemented", "set_up", "tested"}}wheretestedisTrue/False/None(None = not attempted).
- ocracy.status.is_set_up(backend_id)[source]#
Ready to run here & now.
Requires the engine/client to be importable (local and remote), and — for a remote backend — its (primary) credential env var to resolve. So a remote whose key is set but whose client library isn’t installed is not set up (it couldn’t actually run). Returns False for ledger-only backends.
- Return type:
- ocracy.status.is_tested(backend_id, *, image=None)[source]#
Actually run OCR on
image(a generated one if None); True iff it worked.For remote backends this performs a real API call. Returns False if the backend isn’t set up or the run fails.
- Return type:
- ocracy.status.names_with_sites(ids, *, info=None)[source]#
"Name (website), Name2 (website2), ..."forids(name, not id).- Return type:
- ocracy.status.status_table(ids=None, *, info=None, columns=None, run_tests=False, test_image=None)[source]#
Render an aligned Markdown table of backend status (also plain-text readable).
Rows are ordered tested → set-up → implemented → listed, then by name, so the “live” backends float to the top. Pass a precomputed
infoto avoid re-running tests; otherwiserun_testscontrols which set-up backends get OCR-tested.- Return type: