Skip to main content

CAP (Cortex 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/cortex/agent/v1/*.proto
    

    (Or run ./tools/make_protos.sh from repo root and copy generated/python into sdk/python/cap/pb.)

  2. Install:

    pip install -e .
    
  3. Run a worker:

    import asyncio
    from cap import worker
    from cap.pb.cortex.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-1.0.5.tar.gz (7.6 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-1.0.5-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cap_sdk_python-1.0.5.tar.gz
  • Upload date:
  • Size: 7.6 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-1.0.5.tar.gz
Algorithm Hash digest
SHA256 9a649a2c8365f9bc4c82292044995a72c7044bfc1d0eea487df8bc4d142194c8
MD5 f2a841aa5ea8291ab8c22ba21980bd0b
BLAKE2b-256 e16e027fb1fb864a97fc537789bab6079a1af947ac4a2ebd5faa0fa2990eebb3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cap_sdk_python-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 14.3 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-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6f2b69b11ac2fd95d41095298239cadbd5086b844fede1b28ec513647fdccf23
MD5 286a3a68db29b8f31f70378bb10cb3c6
BLAKE2b-256 9b11624e4e74fe513b0c463f0a4675d98f36c1d63e3b8039ba295ffbc59c864f

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