civex-plugin-sdk
SDK for authoring out-of-process civex workflow plugins — subprocess-tier (uv run --script) and container-tier plugins that run as an isolated OS process/container and talk to the host over an RPC wire protocol, rather than importing into civex's own process.
Subclass Plugin, declare its metadata, implement invoke(), and call serve():
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.10"
# dependencies = ["civex-plugin-sdk"]
# ///
from pydantic import BaseModel
from civex_plugin_sdk import Ctx, Plugin as PluginBase, serve
class Plugin(PluginBase):
id = "my_project.compute_duration" # must be unique; use a namespace prefix
name = "Compute Duration"
category = "transforms" # informational only
capabilities = ["get_context_record"] # every ctx.* method this plugin calls
class Config(BaseModel):
start_field: str
end_field: str
def invoke(self, inputs: dict, config: Config, ctx: Ctx) -> dict:
record = ctx.get_context_record()
start = record["data"].get(config.start_field, 0)
end = record["data"].get(config.end_field, 0)
return {"duration": end - start}
if __name__ == "__main__":
serve(Plugin)
Drop the file in _civex/plugins/ in a civex project and it's discovered automatically. See Writing a plugin for the full authoring guide (the Ctx API, isolation/timeouts, constraints), Container plugins for the Tier 2 path, and the SDK reference for the complete public API.
Installing
pip install civex-plugin-sdk # or: uv add civex-plugin-sdk
pip install "civex-plugin-sdk[table]" # adds pandas for `table`-typed inputs/outputs
In a plugin script the PEP 723 header is all you need — uv run resolves it. When civex runs the plugin it pins the SDK to the version civex itself uses, so you don't pin it yourself.
Versioning
The SDK's version comes from sdk-vX.Y.Z git tags (setuptools-scm) — there is no version written in pyproject.toml. civex's own vX.Y.Z tags are a separate namespace. A build between tags is X.Y.Z.postN; only a tagged commit produces a plain release version. requires-python is >=3.10, looser than civex's own >=3.12, since plugins run in their own subprocess/container environment independent of the host's interpreter.
The wire protocol has its own number, civex_plugin_sdk.PROTOCOL_VERSION, which changes only for breaking wire changes; civex refuses a plugin whose protocol it doesn't speak. Release notes are in CHANGELOG.md in the source distribution.
License
MIT — the full text ships in the package as LICENSE. (The civex application itself is under a different license.)
Metadata
Release files for civex-plugin-sdk 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| civex_plugin_sdk-0.2.0.tar.gz | 32.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| civex_plugin_sdk-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 59.0 kB
Release files / civex_plugin_sdk-0.2.0.tar.gz
| Download URL | civex_plugin_sdk-0.2.0.tar.gz |
|---|---|
| Size | 32.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8beaa6d45e10aa3d5086f361babfff1215ba3bcf0bc443cb295ce887ca6fbad1
|
|
BLAKE2b-256 checksum How to use checksums |
df4f2c9d5c43540b9f74c6608144f94ca5e005c2fcaeeaca7959a1484a86082e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / civex_plugin_sdk-0.2.0-py3-none-any.whl
| Download URL | civex_plugin_sdk-0.2.0-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
170fbb295d0fd9764ef37e9e6ef584d414894612762d240c037e80192469498b
|
|
BLAKE2b-256 checksum How to use checksums |
d2f8a410fc992b56425d3b891e4876afbc851869026c232c6acf789a7e7dddb1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|