No description
Find a file
Rui Hu 8de4a20c47
Some checks failed
CI / lint (push) Failing after 3s
CI / typecheck (push) Failing after 4s
CI / behave (3.11) (push) Failing after 3s
CI / behave (3.12) (push) Failing after 3s
CI / behave (3.13) (push) Failing after 3s
CI / docker (push) Has been skipped
CI / helm (push) Has been skipped
CI / build (push) Failing after 4s
/ run-internal-integration-tests (push) Successful in 20m19s
/ publish-python-library (push) Has been skipped
/ should-publish (push) Successful in 5s
/ run-unit-tests (push) Successful in 50s
/ build-and-push-otdemo (push) Successful in 14s
/ run-integration-tests-cleverswarm (push) Successful in 20m55s
Update internal integration test for write default scaling config feature (#112)
This PR updated the internal integration test to follow up the changes in clevermicro/amq-adapter-java#82.

Change list:
+ Update the kubectl file for the java integration demo to adopt new env vars
+ update scaling test script to check if the default value has been written before starting the tests
+ Add mitigation for python otdemo in scaling test since otdemo doesn't have a write default scaling config feature

Reviewed-on: #112
Reviewed-by: Stanislav Hejny <stanislav.hejny@cleverthis.com>
Co-authored-by: Rui Hu <rui.hu@cleverthis.com>
Co-committed-by: Rui Hu <rui.hu@cleverthis.com>
2025-11-25 04:51:33 +00:00
.cursor/rules issue #16 - add model tests, cursor config file and update the tracing.py to setup Jaeger & Prometheus exporters 2025-05-15 00:47:12 +01:00
.devcontainer Merge remote-tracking branch 'base-python/master' into develop 2025-11-08 00:24:30 +00:00
.forgejo Update internal integration test for write default scaling config feature (#112) 2025-11-25 04:51:33 +00:00
benchmarks Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
cleverbrag admin: update code to work with shared base-python base setup 2025-11-08 09:56:48 +00:00
cleverswarm admin: update code to work with shared base-python base setup 2025-11-08 09:56:48 +00:00
container-data feat/#75 - ensure new version is published 2025-09-30 17:39:57 +02:00
docs Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
examples Merge remote-tracking branch 'base-python/master' into develop 2025-11-08 00:24:30 +00:00
features Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
otdemo feat/#89: Implement File streaming protocol to support all addressing modes both on send and receive. Phase 1 that passes unit tests. (#113) 2025-11-24 13:47:36 +00:00
robot Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
scripts Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
src feat/#89: Implement File streaming protocol to support all addressing modes both on send and receive. Phase 1 that passes unit tests. (#113) 2025-11-24 13:47:36 +00:00
tests feat/#89: Implement File streaming protocol to support all addressing modes both on send and receive. Phase 1 that passes unit tests. (#113) 2025-11-24 13:47:36 +00:00
tools feat/#83: cleanup tool, build/publish amq 0.2.69 with more debug prints 2025-11-05 22:24:11 +00:00
typings Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
.bumpversion.cfg Added boilerplate code for python 2024-03-06 23:57:14 -05:00
.cz-config.js Initial commit 2024-01-25 23:10:04 -05:00
.cz.json Initial commit 2024-01-25 23:10:04 -05:00
.dockerignore Merge remote-tracking branch 'base-python/master' into develop 2025-11-08 00:24:30 +00:00
.editorconfig ci: add internal integration demo 2025-11-07 18:43:44 +08:00
.flake8 #43 - fix the issues reported by flake8 2025-05-08 23:52:33 +01:00
.gitattributes Initial commit 2024-01-25 23:10:04 -05:00
.gitignore admin: update code to work with shared base-python base setup 2025-11-08 09:56:48 +00:00
.pre-commit-config.yaml Merge branch 'feat/81-fixes' into feat/81 2025-11-03 19:19:47 +00:00
.python-version Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
AMQ_ROUTE_DUAL_FORMAT.md admin: update code to work with shared base-python base setup 2025-11-08 09:56:48 +00:00
AMQ_ROUTE_FACTORY_FROM_CALLABLE.md admin: update code to work with shared base-python base setup 2025-11-08 09:56:48 +00:00
asv.conf.json Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
ATTRIBUTIONS.md Initial commit 2024-01-25 23:10:04 -05:00
behave.ini Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
CHANGELOG.md Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
CODE_OF_CONDUCT.md Initial commit 2024-01-25 23:10:04 -05:00
compose.yaml feat/#75 - ensure new version is published 2025-09-30 17:39:57 +02:00
CONTRIBUTING.md feat/#75 - ensure new version is published 2025-09-30 17:39:57 +02:00
CONTRIBUTORS.md Initial commit 2024-01-25 23:10:04 -05:00
DEPENDENCIES.md feat/#75: add from_callable to AMQRouteFactory to support register method functionality 2025-09-30 17:40:04 +02:00
docker-compose.yml Modernized build tooling 2025-08-01 18:38:09 -04:00
Dockerfile feat/#90: get ready for using the python demo code correctly, take 1 2025-11-08 17:02:11 +00:00
Dockerfile.amqp-adapter CleverSwarm API invocation example 2025-02-25 20:37:33 +00:00
LICENSE feat/#75 - ensure new version is published 2025-09-30 17:39:57 +02:00
logging.conf Wait keda to ready before deploying clevermicro 2025-10-19 11:50:04 +01:00
METHOD_PARSER_AMQ_ROUTE_INTEGRATION.md admin: update code to work with shared base-python base setup 2025-11-08 09:56:48 +00:00
mkdocs.yml Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
NOTICE Added Apache OSS license 2024-01-25 23:14:00 -05:00
noxfile.py Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
otdemo-entrypoint.sh feat/#90: get ready for using the python demo code correctly, take 1 2025-11-08 17:02:11 +00:00
PRE_COMMIT.md feat/#75: add from_callable to AMQRouteFactory to support register method functionality 2025-09-30 17:40:04 +02:00
pyproject.toml feat/#89: Implement File streaming protocol to support all addressing modes both on send and receive. Phase 1 that passes unit tests. (#113) 2025-11-24 13:47:36 +00:00
pyrightconfig.json Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
README.md admin: update code to work with shared base-python base setup 2025-11-08 09:56:48 +00:00
requirements-dev.txt feat/#75: add from_callable to AMQRouteFactory to support register method functionality 2025-09-30 17:40:04 +02:00
requirements.txt feat/#83 - add cleverswarm dependency and extra debug statements 2025-10-13 15:57:51 +02:00
robot.cfg Significantly revamped the base project to use more robust static checking including benchmarks and integration test support 2025-10-31 16:18:53 -04:00
run_hooks.sh feat/#75: add from_callable to AMQRouteFactory to support register method functionality 2025-09-30 17:40:04 +02:00
run_precommit.sh feat/#75: add from_callable to AMQRouteFactory to support register method functionality 2025-09-30 17:40:04 +02:00
setup-dev.sh feat/#75: add from_callable to AMQRouteFactory to support register method functionality 2025-09-30 17:40:04 +02:00
setup_integration_env_locally.sh feat/#90: synchronize java & python integration testing 2025-11-09 12:57:51 +00:00
start_otdemo.sh feat/#90: get ready for using the python demo code correctly, take 1 2025-11-08 17:02:11 +00:00
TEMP_FILE_CLEANUP_REFACTOR.md feat/#74: remove temp files when the Service call is finished 2025-09-25 10:35:32 +02:00

CleverThis

pipeline status coverage report SemVer Matrix

amq-adapter-python

This project contains the Python implementation of the AMQ adapter for routing the traffic over the RabbitMQ to intended service and automated service discovery.

Usage

Install dependencies

pip install -e .[dev]

This will install dependencies for developing, but won't install this project as an library.

To build the wheel files:

python -m build

The wheel file should be located under dist folder. You can use pip install /path/to/wheel.whl to install this library.

Use as a library

The library has been published to pulp registry at https://pkg.cleverthis.io/pypi/clevermicro/amq-adapter-python/. Configure the dependency amq_adapter with the above registry using your build tools, then:


from src.amqp.service import amq_service

# start using the lib

How to build distributable Wheel archive

install project requirements and dev dependencies pip install -e .[dev]

update version in: pyproject.toml

For dev versions, keep the -dev suffix. The pipeline will replace it with a unique timestamp, act like maven SNAPSHOT versions.

build the distributable archive (will be located in ./dist directory) python -m build --wheel

Development Setup

Pre-commit Hooks

This project uses pre-commit hooks to ensure code quality and consistency. See PRE_COMMIT.md for detailed information.

Quick setup:

# Install pre-commit
pip install pre-commit

# Install hooks
pre-commit install

# Run all hooks manually
./run_precommit.sh

Integrating with actual CleverThis Service

The following steps are required to integrate with the CleverThis service. This example uses ClverSwarm as specific use case, other python-based services would follow identical pattern.

Prerequisites

IMPORTANT: AMQ Adapter relies on the service to use FastAPI to implement its REST endpoints and that those endpoints are properly annotated with FastAPI annotations. AMQ Adapter will look for these annotations to recognize the service API entry points and will automatically use the annotation to map the actual function to the incoming request the very same way FastAPI does.

  1. Install the amq-adapter library, as indicated above
  2. Ensure the needed dependencies were installed together with the amq-adapter. This is the list of dependencies:
aiohttp~=3.11.11
fastapi==0.115.6
aio_pika~=9.5.5
opentelemetry-api
opentelemetry-sdk
opentelemetry-exporter-otlp
opentelemetry-exporter-prometheus
opentelemetry-instrumentation-pika
python_multipart

Go to amq-dapter-python repo source code, and copy the service specific directory, e.g. <git-root>/cleverswarm directory to your service's sources. For the CleverSwarm service, the file is cleverswarm/clever_swarm.py, and contains the AMQ Adapter to CleverSwarm service custom facade, implemented as

class CleverSwarmAmqpAdapter(CleverThisServiceAdapter):

to instatiate and initialize the AMQ adapter, add following line to the init routine of the CleverThis service:

    adapter = CleverSwarmAmqpAdapter(AMQConfiguration("./application.properties.local"))

and ensure that the adapter stays in the context of the service, so it is not garbage collected.

At version 0.2.21, AMQ Adapter uses local configuration file, relative path to which is passed to the AMQConfiguration constructor. This may change in the future, when the central configuration service will become available in CleverMicro, but for now please ensure correct relative path wrt the current working directory.

For the config entries, please refer to the wiki page: AMQ Adapter Config

Environment variables

The AMQ Adapter uses the following environment variables to configure the service:

PARALLEL_WORKERS - number of parallel workers to use for processing incoming requests. This is currently mandatory value, shall be greater than 0.

AMQ_VERBOSE_LOGGING - if set to 1, the adapter will indicate in the log next to the message itself also module name, line and function name where the message was generated

## Donating

[![Open Collective backers](https://img.shields.io/opencollective/all/CleverThis)](https://opencollective.com/cleverthis)

As an open-source project we run entierly off donations. Buy one of our hardworking developers a beer by [donating at OpenCollective](https://opencollective.com/cleverthis). All donations go to our bounty fund and allow us to place bounties on important bugs and enhancements. You may also use Beerpay linked via the above badges.

## Running with Docker Compose

This project includes a Docker Compose configuration for easy local development and testing.

### Prerequisites

- Docker and Docker Compose installed on your system

### Starting the services

```bash
docker-compose up -d

This will start:

Stopping the services

docker-compose down

To remove volumes as well:

docker-compose down -v