Skip to content

Documentation

Python SDK: Sources: workflow inputs and prices

ctx.sources() reads inputs pinned to a workflow and compares prices locally. Arbitrary mail or another run is not accessible.

Examples are fragments inside def run(ctx):. All SDK methods are synchronous; do not add await.

Methods

input

ctx.sources().input(key) -> dict[str, Any]

Argument Type Required Purpose
key str | None Yes Record, state, object, or workflow-input key, depending on the method.

Result: dict[str, Any].

A records input returns records, run_id, collected_at. A mail input returns the checked message, body and attachment metadata. New mail does not replace the pinned message. A newer crawl invalidates the pinned records instead of mixing runs. Deleted or expired mail cannot be read even after the workflow has been queued.

result = ctx.sources().input('catalog')

document

ctx.sources().document(key, id) -> Document

Argument Type Required Purpose
key str | None Yes Record, state, object, or workflow-input key, depending on the method.
id str Yes Authorized attachment/product identifier for this context.

Result: Document. An SDK object; use its methods instead of emitting it directly.

Read a safe attachment belonging to the pinned mail input. Parsing runs inside the system. File contents are not sent to an external model. The shared limit is eight document reads per run.

result = ctx.sources().document('supplier', 'attachment-id')

compare_prices

ctx.sources().compare_prices(sources) -> list[dict[str, Any]]

Argument Type Required Purpose
sources dict[str, list[dict[str, Any]]] Yes Dictionary of 2–10 sources containing sku/price/currency records.

Result: list[dict[str, Any]].

Compare two to ten named sources, each with up to 5000 records containing string sku, numeric price with at most two fractional digits and explicit currency, such as RUB. SKU matching is exact. Negative or invalid prices, repeated SKUs within a source and mixed currencies are rejected.

result = ctx.sources().compare_prices({
    'catalog': [{'sku': 'A-1', 'price': 1250, 'currency': 'RUB'}],
    'supplier': [{'sku': 'A-1', 'price': 1200, 'currency': 'RUB'}],
})

Errors and execution context

All calls are synchronous. Invalid arguments or malformed source data can raise ValueError/TypeError; a platform refusal or unavailable service raises RuntimeError. Missing elements/values return None or an empty collection only where explicitly documented. Do not convert every exception into an empty successful result. External-service methods are unavailable in export transformations; see transformation limits and environment.