From 3365c6b849592ffc64558a791d9c237250200fc2 Mon Sep 17 00:00:00 2001 From: Federico Busetti <729029+febus982@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:41:38 +0000 Subject: [PATCH 1/3] Do not alert if using Dramatiq stub broker for local development --- local.env | 3 ++- src/common/dramatiq.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/local.env b/local.env index c33c1ba3..1f196a80 100644 --- a/local.env +++ b/local.env @@ -1,3 +1,4 @@ +ENVIRONMENT: "local" AUTH__JWKS_URL: "http://oathkeeper:4456/.well-known/jwks.json" -DRAMATIQ__REDIS_URL: "redis://redis:6379/0" +#DRAMATIQ__REDIS_URL: "redis://redis:6379/0" OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317" diff --git a/src/common/dramatiq.py b/src/common/dramatiq.py index 53cee427..901be63b 100644 --- a/src/common/dramatiq.py +++ b/src/common/dramatiq.py @@ -37,8 +37,11 @@ def init_dramatiq(config: AppConfig): else: broker = StubBroker() # broker.emit_after("process_boot") - if config.ENVIRONMENT != "test": - logging.critical("Running a non-test environment without Redis URL set") + if config.ENVIRONMENT not in ["test", "local"]: + logging.critical( + "Running a non-test/non-local environment without Redis URL set", + extra={"ENVIRONMENT": config.ENVIRONMENT} + ) broker.add_middleware(AsyncIO()) set_broker(broker) set_encoder(ORJSONEncoder()) From 9ef49614bebcf107bd2ca1d818953162e623773e Mon Sep 17 00:00:00 2001 From: Federico Busetti <729029+febus982@users.noreply.github.com> Date: Tue, 7 Jan 2025 22:43:06 +0000 Subject: [PATCH 2/3] Remove dramatiq-worker docker dependency --- docker-compose.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f598c1bb..10872178 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -13,7 +13,6 @@ services: volumes: - '.:/app' depends_on: - - dramatiq-worker - otel-collector command: - opentelemetry-instrument @@ -34,7 +33,6 @@ services: context: . target: http_app depends_on: - - dramatiq-worker - otel-collector env_file: local.env environment: From e071d425a386fc314b7b997416bad64013470354 Mon Sep 17 00:00:00 2001 From: Federico Busetti <729029+febus982@users.noreply.github.com> Date: Tue, 7 Jan 2025 23:06:32 +0000 Subject: [PATCH 3/3] Fix tests and lint --- src/common/dramatiq.py | 2 +- tests/common/test_dramatiq.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/dramatiq.py b/src/common/dramatiq.py index 901be63b..cf9234d8 100644 --- a/src/common/dramatiq.py +++ b/src/common/dramatiq.py @@ -40,7 +40,7 @@ def init_dramatiq(config: AppConfig): if config.ENVIRONMENT not in ["test", "local"]: logging.critical( "Running a non-test/non-local environment without Redis URL set", - extra={"ENVIRONMENT": config.ENVIRONMENT} + extra={"ENVIRONMENT": config.ENVIRONMENT}, ) broker.add_middleware(AsyncIO()) set_broker(broker) diff --git a/tests/common/test_dramatiq.py b/tests/common/test_dramatiq.py index 4b1dbb12..4fba5ad0 100644 --- a/tests/common/test_dramatiq.py +++ b/tests/common/test_dramatiq.py @@ -70,4 +70,6 @@ def test_init_dramatiq_without_redis_url(caplog): with caplog.at_level(logging.CRITICAL): init_dramatiq(config) - assert "Running a non-test environment without Redis URL set" in caplog.text + assert ( + "Running a non-test/non-local environment without Redis URL set" in caplog.text + )