Running the Composite Locally
Running the Composite locally.
The service is in composite/backend. It needs Python 3.11 or later (the image uses 3.12), openg2p-fastapi-common from develop (crypto, including PartnerMgmtKeyStore for partner keys from PM, is in openg2p_fastapi_common.crypto) and iam-core from the IAM develop line (the console's staff login).
cd composite/backend
python3.11 -m venv .venv && . .venv/bin/activate
pip install "git+https://github.com/openg2p/openg2p-fastapi-common@develop#subdirectory=openg2p-fastapi-common"
pip install "git+https://github.com/openg2p/iam@develop#subdirectory=iam-core"
pip install -e ".[test]"
pytest # no network needed
openssl ecparam -name prime256v1 -genkey -noout -out /tmp/composite.pem # a test signing key
export AGRI_COMPOSITE_USE_CASES_DIR=../use-cases
export AGRI_COMPOSITE_SIGNING_KEY_PEM_PATH=/tmp/composite.pem AGRI_COMPOSITE_SIGNING_KID=composite-local
export AGRI_COMPOSITE_PARTNER_MGMT_API_URL=http://localhost:9001 # a PM partner-api
export AGRI_COMPOSITE_REGISTRIES='{"farmer-registry":{"url":"http://localhost:9002/dci/registry/sync/search"},
"crop-sown-registry":{"url":"http://localhost:9003/dci/registry/sync/search"}}'
python -m openg2p_agri_composite.main run # http://localhost:8000/docsThe ports are examples: point
PARTNER_MGMT_API_URLandREGISTRIESat a PM partner API and the registries' partner APIs you can reach, e.g. throughkubectl port-forward.The partner's and the Composite's public keys must be in that PM (
PARTNER_BANK_A,PARTNER_AGRI_COMPOSITE; the Composite's fromhttp://localhost:8000/.well-known/jwks.json), and the partner needs a policy there for the use case (loan-profile@1).With the console off (the default outside the chart) the service has no database; startup only loads the use cases. The chart turns the console on, which needs a database, IAM and Redis (see Composite console).
The consent mode is
exchangeby default: setAGRI_COMPOSITE_CONSENT_EXCHANGE_CM_URLto a reachable CM partner API (the default is the in-cluster service), orAGRI_COMPOSITE_CONSENT_MODE=passthroughto skip the Exchange CM.Every setting is listed in Deployment: Composite, environment settings.
Then read it as a partner would:
A signed query needs a partner key in that PM: the test's signing functions show how to build one.
Building the image
The Dockerfile is composite/docker/agri-composite-api/Dockerfile. CI builds and publishes the image (openg2p/openg2p-agri-composite-api) and the chart only when something under composite/ changes, not on documentation-only pushes.
Last updated
Was this helpful?