Skip to content

API Reference parrot.handlers.infographic_recipes

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

parrot.handlers.infographic_recipes

View source

REST handler + scheduler callback for FEAT-324 infographic recipes (Module 8).

Provides REST endpoints for recipe CRUD + on-demand replay:

GET    /api/v1/infographic_recipes              - list recipes (owner-scoped)
GET    /api/v1/infographic_recipes/{name}        - full recipe
PUT    /api/v1/infographic_recipes/{name}        - create/overwrite a recipe
DELETE /api/v1/infographic_recipes/{name}        - delete a recipe
POST   /api/v1/infographic_recipes/{name}/run    - replay (RecipeRunner.run())

Plus a run_infographic_recipe scheduler callback registered on the EXISTING CALLBACK_REGISTRY (parrot.scheduler.functions — AgentSchedulerManager already ships jobs + callbacks; no new scheduler is created here, per spec Non-Goal). Scheduled replays run under the recipe's stored schedule.principal (spec G8) — a missing/unset principal fails the job outright, NEVER falling back to a server identity.

Wiring note: scheduler callback objects are built by build_scheduler_callback(definition, logger=...) from static, JSON- serializable job config ONLY (see scheduler/functions/__init__.py) — they have no access to the aiohttp app or any live singleton. Call :func:configure_recipe_runner once at server startup (alongside :func:register_recipe_routes) so run_infographic_recipe jobs have a RecipeRunner to use.

Class RecipeHandler

CRUD + run REST handler for infographic recipes (FEAT-324, Module 8).

Attributes:

Attribute Type Description
store AbstractRecipeStore
runner RecipeRunner

Method RecipeHandler.post_init

post_init(*args, **kwargs) -> None

Parameter Type Default Description
*args ()
**kwargs {}

Method RecipeHandler.get

List recipes, or fetch one by name.

get() -> web.Response

Returns: web.Response

Method RecipeHandler.put

Create or overwrite a recipe.

put() -> web.Response

Returns: web.Response

Method RecipeHandler.delete

Delete a recipe.

delete() -> web.Response

Returns: web.Response

Method RecipeHandler.post

Replay a recipe.

post() -> web.Response

Returns: web.Response

Class RunInfographicRecipeCallback

Scheduler callback replaying a saved recipe (FEAT-324, spec G6/G8).

The targeted recipe MUST have schedule.principal set. It is resolved into a PermissionContext via build_principal_context — using schedule.tenant_id/schedule.roles when the recipe author set them, falling back to tenant_id=principal/no roles otherwise (a documented simplification, not a silent bug: policies keyed on real tenant ids or roles should set schedule.tenant_id/schedule.roles explicitly). A missing principal, or a missing runner, fails the job outright rather than silently widening access — this is the part spec G8's core acceptance criterion actually requires ("never fall back to a server identity").

Method RunInfographicRecipeCallback.run

run(result: Any, *, schedule_id: str, target_name: str, **kwargs) -> Dict[str, Any]

Parameter Type Default Description
result Any
schedule_id str
target_name str
**kwargs {}

Returns: Dict[str, Any]

Function configure_recipe_runner

Set the process-wide RecipeRunner used by the scheduler callback.

configure_recipe_runner(runner: RecipeRunner) -> None

Parameter Type Default Description
runner RecipeRunner The configured RecipeRunner (store + dataset manager).

Function get_recipe_runner

Return the process-wide RecipeRunner set via :func:configure_recipe_runner.

get_recipe_runner() -> Optional[RecipeRunner]

Returns: Optional[RecipeRunner]

Function register_recipe_routes

Configure the recipe store/runner for RecipeHandler and the scheduler callback.

Routes themselves are registered unconditionally in manager.py (mirroring the DatasetManagerHandler precedent) — this function ONLY wires the store/runner onto app (so RecipeHandler resolves them) and onto the process-wide singleton the run_infographic_recipe scheduler callback reads (callback objects are built from static JSON job config only — see the module docstring's Wiring note — so they cannot reach app directly).

register_recipe_routes(app: web.Application, *, recipe_store: AbstractRecipeStore, recipe_runner: Optional[RecipeRunner] = None, dataset_manager: Any = None, artifact_store: Any = None) -> RecipeRunner

Parameter Type Default Description
app web.Application The aiohttp application.
recipe_store AbstractRecipeStore The configured AbstractRecipeStore.
recipe_runner Optional[RecipeRunner] None A pre-built RecipeRunner; takes precedence over dataset_manager (below) if both are given.
dataset_manager Any None Used to build a RecipeRunner when recipe_runner is not supplied directly.
artifact_store Any None Forwarded to the built RecipeRunner (only used when building one from dataset_manager).

Returns: RecipeRunner — The RecipeRunner now wired on app["recipe_runner"] and as the scheduler callback's process-wide runner.

Raises:

  • ValueError — If neither recipe_runner nor dataset_manager is given.

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