Skip to main content

CAP (coretex Agent Protocol) Python SDK

Project description

CAP Python SDK

Asyncio-first SDK with NATS helpers for CAP workers and clients.

Quick Start

  1. Generate protobuf stubs into this SDK (one-time per proto change):

    python -m grpc_tools.protoc \
      -I../../proto \
      --python_out=./cap/pb \
      --grpc_python_out=./cap/pb \
      ../../proto/coretex/agent/v1/*.proto
    

    (Or run ./tools/make_protos.sh from repo root with CAP_RUN_PY=1 and copy /python into sdk/python/cap/pb if you want vendored stubs.)

  2. Install:

    pip install -e .
    
  3. Run a worker:

    import asyncio
    from cap import worker
    from cap.pb.coretex.agent.v1 import job_pb2
    
    async def handle(req: job_pb2.JobRequest):
        return job_pb2.JobResult(
            job_id=req.job_id,
            status=job_pb2.JOB_STATUS_SUCCEEDED,
            result_ptr=f"redis://res/{req.job_id}",
            worker_id="worker-echo-1",
        )
    
    asyncio.run(worker.run_worker("nats://127.0.0.1:4222", "job.echo", handle))
    

Files

  • cap/bus.py — NATS connector.
  • cap/worker.py — worker skeleton with handler hook.
  • cap/client.py — publish JobRequest to sys.job.submit.
  • cap/pb/ — protobuf stubs (generated).

Defaults

  • Subjects: sys.job.submit, sys.job.result, sys.heartbeat.
  • Protocol version: 1.

Swap out cap.bus if you need a different transport.

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

cap_sdk_python-2.0.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

cap_sdk_python-2.0.2-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file cap_sdk_python-2.0.2.tar.gz.

File metadata

  • Download URL: cap_sdk_python-2.0.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cap_sdk_python-2.0.2.tar.gz
Algorithm Hash digest
SHA256 b2905912a3032d8c92c6f41e285aaf120322ea35edb8236642663fdb50d6a293
MD5 acdc98c890f1bc6b8edb9aea3c8593f4
BLAKE2b-256 f0ea1ca36d073831f70536919606ff7cddec5dc00509ffcaaac9a64a49d2b895

See more details on using hashes here.

File details

Details for the file cap_sdk_python-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: cap_sdk_python-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cap_sdk_python-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1319b3b8d1342df07421d7613712c451fd17b1f235d0bb8fb9d62ac485f7476a
MD5 a941229bc122bb00b0f93734d408658b
BLAKE2b-256 3a2c5798ac1013619d39cab929c79b00679ef655cf7e7ed62dc33ad7aa0e4d1f

See more details on using hashes here.

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