From ed17eadd29e834d89f976110476e08ad1f65f83b Mon Sep 17 00:00:00 2001 From: Mike Shultz Date: Wed, 24 Apr 2024 09:15:06 -0600 Subject: [PATCH 1/3] fix(devops): do not use macos-latest until there's a setup-python fix (#73) --- .github/workflows/test.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 88831344..4a9eabc2 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -62,7 +62,9 @@ jobs: strategy: matrix: - os: [ubuntu-latest, macos-latest] # eventually add `windows-latest` + # TODO: Replace with macos-latest when works again. + # https://github.com/actions/setup-python/issues/808 + os: [ubuntu-latest, macos-12] # eventually add `windows-latest` python-version: [3.8, 3.9, "3.10", "3.11"] steps: From 5e7f51342f38cb7a1f10072841c885348a6385b6 Mon Sep 17 00:00:00 2001 From: Mike Shultz Date: Sat, 27 Apr 2024 11:56:40 -0600 Subject: [PATCH 2/3] fix: label issues (#72) * fix: pop throws exception on non-existant key * fix: apply contract event labels to task when appropriate * fix: type errors * style: update label pop code for clarity * refactor: use event signature in label instead of dumping whole EventABI model * chore: add ethpm-types direct dependency --- setup.py | 1 + silverback/application.py | 10 +++++++++- silverback/middlewares.py | 4 +++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index bd8015d9..771965f8 100644 --- a/setup.py +++ b/setup.py @@ -69,6 +69,7 @@ install_requires=[ "click", # Use same version as eth-ape "eth-ape>=0.7.0,<1.0", + "ethpm-types>=0.6.10", # lower pin only, `eth-ape` governs upper pin "eth-pydantic-types", # Use same version as eth-ape "pydantic_settings", # Use same version as eth-ape "taskiq[metrics]>=0.10.4,<0.11.0", diff --git a/silverback/application.py b/silverback/application.py index b04eea34..1a07e6f0 100644 --- a/silverback/application.py +++ b/silverback/application.py @@ -118,10 +118,18 @@ def broker_task_decorator( # Register user function as task handler with our broker def add_taskiq_task(handler: Callable) -> AsyncTaskiqDecoratedTask: + labels = {"task_type": str(task_type)} + + if container and isinstance(container, ContractEvent): + # Address is almost a certainty if the container is being used as a filter here. + if contract_address := getattr(container.contract, "address", None): + labels["contract_address"] = contract_address + labels["event_signature"] = container.abi.signature + broker_task = self.broker.register_task( handler, task_name=handler.__name__, - task_type=str(task_type), + **labels, ) self.tasks[task_type].append(TaskData(container=container, handler=broker_task)) diff --git a/silverback/middlewares.py b/silverback/middlewares.py index 18c6c72f..b4673902 100644 --- a/silverback/middlewares.py +++ b/silverback/middlewares.py @@ -56,9 +56,11 @@ def _create_label(self, message: TaskiqMessage) -> str: return message.task_name def pre_execute(self, message: TaskiqMessage) -> TaskiqMessage: - if not (task_type := message.labels.pop("task_type")): + if "task_type" not in message.labels: return message # Not a silverback task + task_type = message.labels.pop("task_type") + try: task_type = TaskType(task_type) except ValueError: From f581ecf4ffc8ae3f4b1628aaa85967311aa8c3e5 Mon Sep 17 00:00:00 2001 From: Mike Shultz Date: Wed, 1 May 2024 00:37:24 -0600 Subject: [PATCH 3/3] chore: update docker container to python 3.11 (#74) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e836b859..c4acd160 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------------------------- # Build with builder image to reduce image size -FROM python:3.10 as builder +FROM python:3.11 as builder USER root WORKDIR /wheels COPY . .