Skip to content

API Reference parrot.knowledge.ontology.concept_catalog.seed

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.knowledge.ontology.concept_catalog.seed

View source

Concept Catalog YAML seed utility (FEAT-159 TASK-1090).

Seeds concept rows from an existing YAML ontology file into the Postgres concept catalog. The function is idempotent: concepts whose (tenant_id, slug) already exist in any state are silently skipped.

Usage (example)::

import asyncpg
from parrot.knowledge.ontology.concept_catalog.service import ConceptCatalogService
from parrot.knowledge.ontology.concept_catalog.seed import seed_concepts_from_yaml

pool = await asyncpg.create_pool(dsn)
svc  = ConceptCatalogService(pool)
seeded = await seed_concepts_from_yaml("my-tenant", Path("base.ontology.yaml"), svc)
print(f"Seeded {seeded} concepts.")

Alias ConceptCatalogService

Re-exported from parrot.knowledge.ontology.concept_catalog.service.ConceptCatalogService.

Alias SynonymConflictError

Re-exported from parrot.knowledge.ontology.exceptions.SynonymConflictError.

Attribute logger

Function seed_concepts_from_yaml

Seed concept rows from a YAML ontology file.

Reads each entity defined in the YAML and proposes + approves it as a concept in the catalog. The seed is idempotent: if a concept with the same (tenant_id, slug) already exists (in any state), it is skipped.

asserted_by is set to "seed:yaml@<sha256[:12]>" so audit logs can trace every row back to the source file and its content hash.

is_a edges are seeded after all concepts, so parent IDs are available. YAML hierarchy is encoded as parent_entity or parent keys on each entity block (non-standard extension; falls back to no edge if absent).

seed_concepts_from_yaml(tenant_id: str, yaml_path: Path, service: ConceptCatalogService) -> int

Parameter Type Default Description
tenant_id str Tenant to seed concepts into.
yaml_path Path Path to the ontology YAML file.
service ConceptCatalogService ConceptCatalogService instance (already connected to pool).

Returns: int — Number of new concepts actually seeded (skipped rows not counted).

Raises:

  • FileNotFoundError — If yaml_path does not exist.
  • yaml.YAMLError — If the file cannot be parsed.

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