Skip to content

API Reference parrot.services.comm_center.ingest

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

parrot.services.comm_center.ingest

View source

Recipient ingestion — normalize the three CommCenter transports.

ingest_recipients is the single entry point that turns any of the three accepted transports (inline JSON rows, a multipart-uploaded file already saved to disk by BaseHandler.handle_upload, or a base64-decoded file's raw bytes) into an identical list[RecipientIn] (spec §2 G2, §3 Module 4).

Column names are normalized case-insensitively, trimmed, and alias-mapped (e-mail -> email, nombre -> name, etc.); any column beyond the canonical five is preserved verbatim in RecipientIn.extra so it becomes a valid pass-2 placeholder downstream. All pandas parsing runs off the event loop via asyncio.to_thread — never call it directly.

Class FileTooLargeError

Raised when the uploaded payload exceeds :data:MAX_FILE_SIZE.

Class IngestionError

Base class for all recipient-ingestion validation failures.

Attribute MAX_FILE_SIZE

Attribute MAX_RECIPIENTS

Class RecipientCapExceededError

Raised when the parsed row count exceeds :data:MAX_RECIPIENTS.

Alias RecipientIn

Re-exported from parrot.services.comm_center.models.RecipientIn.

Function ingest_recipients

Normalize any one of the three CommCenter transports into recipients.

Exactly one of rows, file_path, or file_bytes must be provided. file_path is the multipart transport (the handler already wrote the upload to a temp file via BaseHandler.handle_upload); file_bytes is the base64-embedded transport (already decoded by the caller); rows is the inline-JSON transport.

ingest_recipients(*, rows: list[dict] | None = None, file_path: str | Path | None = None, file_bytes: bytes | None = None, filename: str | None = None, return_warnings: bool = False) -> list[RecipientIn] | tuple[list[RecipientIn], list[str]]

Parameter Type Default Description
rows list[dict] | None None Inline JSON recipient rows (list of plain dicts).
file_path str | Path | None None Path to a CSV/XLSX file already saved to disk.
file_bytes bytes | None None Raw (already base64-decoded) CSV/XLSX file content.
filename str | None None Original filename for file_bytes, used to pick the CSV vs. Excel parser. Required when file_bytes is given.
return_warnings bool False When True, return (recipients, warnings) instead of just recipients.

Returns: list[RecipientIn] | tuple[list[RecipientIn], list[str]] — The normalized recipients, or a (recipients, warnings) tuple when return_warnings is True. Rows with no usable name (the one mandatory canonical field) are skipped rather than raised — one malformed row must never abort ingestion for the rest of the batch; the skip count is logged and included in warnings.

Raises:

  • FileTooLargeError — The payload exceeds :data:MAX_FILE_SIZE.
  • RecipientCapExceededError — More than :data:MAX_RECIPIENTS rows.
  • IngestionError — The file is empty, has none of the recognized recipient columns, or every row lacked a usable name.

Attribute logger

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