Skip to main content

Framework-neutral Python SDK for building LAREX Action processors.

Project description

LAREX Action SDK

This SDK is work in progress. The public API can still change before LAREX Actions and the SDK are considered stable.

Framework-neutral Python SDK for building LAREX Action processors.

The core package verifies LAREX dispatch requests, parses typed run/input payloads, sends heartbeats, downloads selected files, and uploads result manifests. FastAPI support is available as an optional convenience extra.

Installation

uv add "larex-action-sdk[fastapi]"

For framework-neutral usage only:

uv add larex-action-sdk

FastAPI Processor

import os

from larex_actions import ActionContext
from larex_actions.fastapi import create_larex_action_app


async def process(ctx: ActionContext) -> None:
    action_input = await ctx.pull_input()
    results = ctx.result_builder()

    for page in action_input.pages:
        await ctx.heartbeat(25, f"Processing {page.name}", raise_on_cancel=True)
        if page.xml:
            xml_bytes = await ctx.download_bytes(page.xml[0])
            results.add_xml_bytes(
                page_id=page.id,
                content=xml_bytes,
                file_name=f"{page.name}-processed.xml",
            )

    await ctx.complete(results, "Done")


app = create_larex_action_app(
    processor_id="my-processor",
    dispatch_secret=os.environ["LAREX_DISPATCH_HMAC_SECRET"],
    handler=process,
)

Framework-Neutral Dispatch Verification

from larex_actions import DispatchVerifier

payload = DispatchVerifier(
    processor_id="my-processor",
    dispatch_secret=secret,
).verify(
    method=request_method,
    path_and_query=request_path_and_query,
    headers=request_headers,
    body=request_body,
)

You can then pass payload.model_dump(mode="json", by_alias=True) to your own queue/worker system and use ActionClient.from_dispatch(payload) in async workers.

Security

  • Dispatch requests are verified with the X-LAREX-Action-* HMAC headers.
  • Timestamps and nonces are checked to reduce replay risk.
  • Per-run bearer secrets and dispatch HMAC secrets are never included in model reprs.
  • Processor YAML must still declare the inputs and outputs LAREX should expose or accept.

Development

uv sync --all-extras
uv run ruff format .
uv run ruff check .
uv run pyright
uv run pytest
uv build

Releases are published with PyPI Trusted Publishing from GitHub Actions. Release candidate tags containing rc publish to TestPyPI; published GitHub releases publish to PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

larex_action_sdk-0.1.2.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larex_action_sdk-0.1.2-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file larex_action_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: larex_action_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for larex_action_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dfb5e6ff395a6e079c711f49f14de3bfc442fd72a775f3a3c3a4476d5d0ccdb3
MD5 4ff37a2397c9c16dd38df6a5499a2aae
BLAKE2b-256 694ad7fdfb6405c0ec97f97d9d26146577124d4b39b7a1587de83eaeff8bc675

See more details on using hashes here.

Provenance

The following attestation bundles were made for larex_action_sdk-0.1.2.tar.gz:

Publisher: publish.yml on OCR4all/larex-action-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file larex_action_sdk-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for larex_action_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f1510458c2eff1f9114d7f109e37fa804bb1935e2115ff3f3502f997943aee8e
MD5 c034a536f91edd38aa5d2432de0a71e4
BLAKE2b-256 2b37a299f3ac3f8d45540dd1ccdde7417a6c2bc3df3dc063e18b72da262641ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for larex_action_sdk-0.1.2-py3-none-any.whl:

Publisher: publish.yml on OCR4all/larex-action-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page