Skip to content

API Reference parrot.tools.infographic_recipes.loader

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

parrot.tools.infographic_recipes.loader

View source

load_transformer_module — host-side loader for a recipe's transformers (FEAT-528).

A host that wants to replay a recipe needs its @infographic_transformer functions registered in-process — and nothing else from the agent that ships them: no class, no LLM, no toolkit. Today, registration is purely an import side effect, and the only way to trigger it is a module import; this helper imports a transformer module by file location so a host can register those functions without owning a package named the same as the module's real parent (spec §3 Module 2, item 3).

Function load_transformer_module

Import a transformer module by file path so its transformers register.

If the module's directory contains an __init__.py, the module is loaded AS A SUBMODULE of a synthetic package (registered in sys.modules under a deterministic synthetic name) so that relative imports inside the module (e.g. from .normalize import ...) resolve. Otherwise the file is loaded directly under a synthetic module name.

Loading the same resolved path twice is idempotent: the second call returns the already-imported module from sys.modules without re-executing it (so its @infographic_transformer functions are never registered twice). The same holds when the module was FIRST imported through its ordinary package path (import pkg.transformers): the existing module is returned rather than re-executed under a synthetic name. First loads are serialised by a process-wide lock.

load_transformer_module(path: str | Path, *, name: str | None = None) -> ModuleType

Parameter Type Default Description
path str | Path Path to the transformer module file (e.g. .../flex_dashboard/transformers.py).
name str | None None Optional explicit synthetic name. Defaults to a deterministic name derived from the resolved path.

Returns: ModuleType — The imported module.

Raises:

  • FileNotFoundError — If path does not resolve to an existing file.
  • ImportError — Re-raised unchanged if importing the module fails.

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