Skip to content

API Reference parrot.semantic.accounting.catalog

github-actions[bot] edited this page Dec 2, 2026 · 1 revision

parrot.semantic.accounting.catalog

View source

Tenant-scoped catalog of accounting models (FEAT-713 M8).

Alias AccountingModel

Re-exported from parrot.semantic.accounting.models.AccountingModel.

Alias AccountingModelSpec

Re-exported from parrot.semantic.accounting.models.AccountingModelSpec.

Alias ChartSnapshot

Re-exported from parrot.semantic.accounting.models.ChartSnapshot.

Attribute Key

Alias MetricDef

Re-exported from parrot.semantic.accounting.models.MetricDef.

Class ModelCatalog

Indexes <models_dir>/<tenant>/<model>.yaml specs; loads selected models atomically.

Specs are parsed once at construction and are available without any chart snapshot. Models are loaded only for the keys a caller supplies snapshots for; each batch is validated in full before it is published by swapping the model mapping under a lock, so readers never observe a partially loaded batch.

Parameter Type Default Description
models_dir Path Root directory holding one sub-directory per tenant. A missing directory yields an empty catalog.

Method ModelCatalog.specs

Parsed YAML specs keyed (tenant, model) — available before snapshots exist.

specs() -> dict[Key, AccountingModelSpec]

Returns: dict[Key, AccountingModelSpec]

Method ModelCatalog.load

Load only supplied keys; validate the whole batch before atomic publication.

load(snapshots: Mapping[Key, ChartSnapshot], columns: Mapping[Key, Mapping[str, str]] | None = None) -> None

Parameter Type Default Description
snapshots Mapping[Key, ChartSnapshot] Chart snapshot per (tenant, model) to load.
columns Mapping[Key, Mapping[str, str]] | None None Optional journal column types per key, forwarded to load-time validation.

Raises:

  • KeyError — When a key is not in the catalog (nothing is published).
  • ModelValidationError — When any model of the batch fails validation or its identity no longer matches its path; carries every problem of the batch and names each failing file (nothing is published).

Method ModelCatalog.reload

Validate replacements before atomic publication; caller invalidates replaced model hashes.

reload(snapshots: Mapping[Key, ChartSnapshot], columns: Mapping[Key, Mapping[str, str]] | None = None) -> None

Parameter Type Default Description
snapshots Mapping[Key, ChartSnapshot]
columns Mapping[Key, Mapping[str, str]] | None None

Method ModelCatalog.get

The loaded model; KeyError when not loaded.

get(tenant: str, model: str) -> AccountingModel

Parameter Type Default Description
tenant str
model str

Returns: AccountingModel

Method ModelCatalog.is_loaded

Whether (tenant, model) has a published model.

is_loaded(tenant: str, model: str) -> bool

Parameter Type Default Description
tenant str
model str

Returns: bool

Method ModelCatalog.metrics

(model, metric name, definition) from parsed specs for one tenant; no snapshot access.

metrics(tenant: str) -> list[tuple[str, str, MetricDef]]

Parameter Type Default Description
tenant str

Returns: list[tuple[str, str, MetricDef]]

Method ModelCatalog.flags

The latest live status recorded for (tenant, model), if any.

flags(tenant: str, model: str) -> 'ModelLiveStatus | None'

Parameter Type Default Description
tenant str
model str

Returns: 'ModelLiveStatus | None'

Method ModelCatalog.set_flags

Record status for its (status.tenant, status.model).

set_flags(status: 'ModelLiveStatus') -> None

Parameter Type Default Description
status 'ModelLiveStatus'

Alias ModelLiveStatus

Re-exported from parrot.semantic.accounting.live.ModelLiveStatus.

Alias ModelValidationError

Re-exported from parrot.semantic.accounting.errors.ModelValidationError.

Alias Problem

Re-exported from parrot.semantic.accounting.errors.Problem.

Attribute SnapshotProvider

Alias load_model

Re-exported from parrot.semantic.accounting.loader.load_model.

Alias load_spec

Re-exported from parrot.semantic.accounting.loader.load_spec.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally