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",
variant="processed",
)
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file larex_action_sdk-0.1.1.tar.gz.
File metadata
- Download URL: larex_action_sdk-0.1.1.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb50e8110b0869da3e115a34b1880d56843b30312d4ea1d6de7daa619be1d9f1
|
|
| MD5 |
c20ca64249907b9613953fcdfb414520
|
|
| BLAKE2b-256 |
6ff1928412b28c22d8299b993b6c3b18be64b3222ce160466a06c485c4d65d53
|
Provenance
The following attestation bundles were made for larex_action_sdk-0.1.1.tar.gz:
Publisher:
publish.yml on OCR4all/larex-action-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
larex_action_sdk-0.1.1.tar.gz -
Subject digest:
cb50e8110b0869da3e115a34b1880d56843b30312d4ea1d6de7daa619be1d9f1 - Sigstore transparency entry: 1473197723
- Sigstore integration time:
-
Permalink:
OCR4all/larex-action-sdk@54a4e509b6d5f7e8b41221e214ab3bfb12c83e73 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/OCR4all
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@54a4e509b6d5f7e8b41221e214ab3bfb12c83e73 -
Trigger Event:
release
-
Statement type:
File details
Details for the file larex_action_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: larex_action_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56d8f3661f15b1a357ea4d58043cc817b020b91340bd3ed1b3d490cfbb105564
|
|
| MD5 |
5534e433ff14f2949b01ee0dc5317c77
|
|
| BLAKE2b-256 |
8a0d2a41f0a2e15476dc384444e43c0e52a8d42b606e97831a357a74097be347
|
Provenance
The following attestation bundles were made for larex_action_sdk-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on OCR4all/larex-action-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
larex_action_sdk-0.1.1-py3-none-any.whl -
Subject digest:
56d8f3661f15b1a357ea4d58043cc817b020b91340bd3ed1b3d490cfbb105564 - Sigstore transparency entry: 1473197906
- Sigstore integration time:
-
Permalink:
OCR4all/larex-action-sdk@54a4e509b6d5f7e8b41221e214ab3bfb12c83e73 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/OCR4all
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@54a4e509b6d5f7e8b41221e214ab3bfb12c83e73 -
Trigger Event:
release
-
Statement type: