Skip to content

Commit 1202074

Browse files
committed
Revert "make sure celery tasks actually run"
This reverts commit 07ee77a.
1 parent b71cbca commit 1202074

File tree

6 files changed

+34
-280
lines changed

6 files changed

+34
-280
lines changed

packages/celery-library/requirements/_test.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111
# testing
1212
coverage
1313
faker
14-
fakeredis
1514
fastapi
1615
docker
1716
httpx
1817
pint
1918
pytest
2019
pytest-asyncio
2120
pytest-benchmark
22-
pytest-celery
2321
pytest-cov
2422
pytest-icdiff
2523
pytest-instafail
Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
amqp==5.3.1
2-
# via
3-
# -c requirements/_base.txt
4-
# kombu
51
annotated-types==0.7.0
62
# via
73
# -c requirements/_base.txt
@@ -11,14 +7,6 @@ anyio==4.9.0
117
# -c requirements/_base.txt
128
# httpx
139
# starlette
14-
billiard==4.2.1
15-
# via
16-
# -c requirements/_base.txt
17-
# celery
18-
celery==5.5.2
19-
# via
20-
# -c requirements/_base.txt
21-
# pytest-celery
2210
certifi==2025.4.26
2311
# via
2412
# -c requirements/../../../requirements/constraints.txt
@@ -30,39 +18,13 @@ charset-normalizer==3.4.2
3018
# via
3119
# -c requirements/_base.txt
3220
# requests
33-
click==8.2.1
34-
# via
35-
# -c requirements/_base.txt
36-
# celery
37-
# click-didyoumean
38-
# click-plugins
39-
# click-repl
40-
click-didyoumean==0.3.1
41-
# via
42-
# -c requirements/_base.txt
43-
# celery
44-
click-plugins==1.1.1
45-
# via
46-
# -c requirements/_base.txt
47-
# celery
48-
click-repl==0.3.0
49-
# via
50-
# -c requirements/_base.txt
51-
# celery
5221
coverage==7.8.2
5322
# via
5423
# -r requirements/_test.in
5524
# pytest-cov
56-
debugpy==1.8.14
57-
# via pytest-celery
5825
docker==7.1.0
59-
# via
60-
# -r requirements/_test.in
61-
# pytest-celery
62-
# pytest-docker-tools
63-
faker==37.3.0
6426
# via -r requirements/_test.in
65-
fakeredis==2.29.0
27+
faker==37.3.0
6628
# via -r requirements/_test.in
6729
fastapi==0.115.12
6830
# via -r requirements/_test.in
@@ -88,11 +50,6 @@ idna==3.10
8850
# requests
8951
iniconfig==2.1.0
9052
# via pytest
91-
kombu==5.5.3
92-
# via
93-
# -c requirements/_base.txt
94-
# celery
95-
# pytest-celery
9653
packaging==25.0
9754
# via
9855
# -c requirements/_base.txt
@@ -106,14 +63,6 @@ pluggy==1.6.0
10663
# via pytest
10764
pprintpp==0.4.0
10865
# via pytest-icdiff
109-
prompt-toolkit==3.0.51
110-
# via
111-
# -c requirements/_base.txt
112-
# click-repl
113-
psutil==7.0.0
114-
# via
115-
# -c requirements/_base.txt
116-
# pytest-celery
11766
py-cpuinfo==9.0.0
11867
# via pytest-benchmark
11968
pydantic==2.11.5
@@ -125,17 +74,12 @@ pydantic-core==2.33.2
12574
# via
12675
# -c requirements/_base.txt
12776
# pydantic
128-
pyjwt==2.9.0
129-
# via
130-
# -c requirements/_base.txt
131-
# redis
13277
pytest==8.3.5
13378
# via
13479
# -r requirements/_test.in
13580
# pytest-asyncio
13681
# pytest-benchmark
13782
# pytest-cov
138-
# pytest-docker-tools
13983
# pytest-icdiff
14084
# pytest-instafail
14185
# pytest-mock
@@ -144,12 +88,8 @@ pytest-asyncio==1.0.0
14488
# via -r requirements/_test.in
14589
pytest-benchmark==5.1.0
14690
# via -r requirements/_test.in
147-
pytest-celery==1.2.0
148-
# via -r requirements/_test.in
14991
pytest-cov==6.1.1
15092
# via -r requirements/_test.in
151-
pytest-docker-tools==3.1.9
152-
# via pytest-celery
15393
pytest-icdiff==0.9
15494
# via -r requirements/_test.in
15595
pytest-instafail==0.5.0
@@ -160,10 +100,6 @@ pytest-runner==6.0.1
160100
# via -r requirements/_test.in
161101
pytest-sugar==1.0.0
162102
# via -r requirements/_test.in
163-
python-dateutil==2.9.0.post0
164-
# via
165-
# -c requirements/_base.txt
166-
# celery
167103
python-dotenv==1.1.0
168104
# via
169105
# -c requirements/_base.txt
@@ -173,35 +109,18 @@ pyyaml==6.0.2
173109
# -c requirements/../../../requirements/constraints.txt
174110
# -c requirements/_base.txt
175111
# -r requirements/_test.in
176-
redis==5.3.0
177-
# via
178-
# -c requirements/../../../requirements/constraints.txt
179-
# -c requirements/_base.txt
180-
# fakeredis
181112
requests==2.32.3
182113
# via
183114
# -c requirements/_base.txt
184115
# docker
185-
setuptools==80.9.0
186-
# via pytest-celery
187-
six==1.17.0
188-
# via
189-
# -c requirements/_base.txt
190-
# python-dateutil
191116
sniffio==1.3.1
192117
# via
193118
# -c requirements/_base.txt
194119
# anyio
195-
sortedcontainers==2.4.0
196-
# via fakeredis
197120
starlette==0.46.2
198121
# via
199122
# -c requirements/../../../requirements/constraints.txt
200123
# fastapi
201-
tenacity==9.1.2
202-
# via
203-
# -c requirements/_base.txt
204-
# pytest-celery
205124
termcolor==3.1.0
206125
# via pytest-sugar
207126
typing-extensions==4.13.2
@@ -223,20 +142,9 @@ tzdata==2025.2
223142
# via
224143
# -c requirements/_base.txt
225144
# faker
226-
# kombu
227145
urllib3==2.4.0
228146
# via
229147
# -c requirements/../../../requirements/constraints.txt
230148
# -c requirements/_base.txt
231149
# docker
232150
# requests
233-
vine==5.1.0
234-
# via
235-
# -c requirements/_base.txt
236-
# amqp
237-
# celery
238-
# kombu
239-
wcwidth==0.2.13
240-
# via
241-
# -c requirements/_base.txt
242-
# prompt-toolkit

packages/celery-library/requirements/_tools.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ cfgv==3.4.0
1111
click==8.2.1
1212
# via
1313
# -c requirements/_base.txt
14-
# -c requirements/_test.txt
1514
# black
1615
# pip-tools
1716
dill==0.4.0
@@ -71,9 +70,7 @@ pyyaml==6.0.2
7170
ruff==0.11.11
7271
# via -r requirements/../../../requirements/devenv.txt
7372
setuptools==80.9.0
74-
# via
75-
# -c requirements/_test.txt
76-
# pip-tools
73+
# via pip-tools
7774
tomlkit==0.13.2
7875
# via pylint
7976
typing-extensions==4.13.2
Lines changed: 0 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +0,0 @@
1-
from collections.abc import AsyncIterator, Awaitable, Callable
2-
from functools import partial
3-
from typing import Final
4-
5-
import pytest
6-
from asgi_lifespan import LifespanManager
7-
from celery import Celery
8-
from celery.contrib.testing.worker import TestWorkController, start_worker
9-
from celery.signals import worker_init, worker_shutdown
10-
from celery.worker.worker import WorkController
11-
from celery_library import setup_celery_client
12-
from celery_library.routes.rpc import router as async_jobs_router
13-
from celery_library.signals import on_worker_init, on_worker_shutdown
14-
from celery_library.utils import get_celery_worker
15-
from celery_library.worker import CeleryTaskWorker
16-
from faker import Faker
17-
from fastapi import FastAPI
18-
from models_library.products import ProductName
19-
from models_library.rabbitmq_basic_types import RPCNamespace
20-
from models_library.users import UserID
21-
from pydantic import TypeAdapter
22-
from servicelib.rabbitmq import RabbitMQRPCClient
23-
from settings_library.celery import CelerySettings
24-
from settings_library.rabbit import RabbitSettings
25-
from settings_library.redis import RedisSettings
26-
27-
pytest_simcore_core_services_selection = [
28-
"rabbit",
29-
"redis",
30-
"postgres",
31-
]
32-
33-
pytest_plugins = [
34-
"pytest_simcore.docker_compose",
35-
"pytest_simcore.docker_swarm",
36-
"pytest_simcore.rabbit_service",
37-
"pytest_simcore.redis_service",
38-
"pytest_simcore.repository_paths",
39-
]
40-
41-
_LIFESPAN_TIMEOUT: Final[int] = 10
42-
43-
44-
@pytest.fixture
45-
def rpc_namespace() -> RPCNamespace:
46-
return TypeAdapter(RPCNamespace).validate_python("test")
47-
48-
49-
@pytest.fixture
50-
def celery_settings(
51-
rabbit_service: RabbitSettings,
52-
redis_service: RedisSettings,
53-
) -> CelerySettings:
54-
return CelerySettings.create_from_envs()
55-
56-
57-
@pytest.fixture
58-
async def initialized_fast_api(
59-
rabbitmq_rpc_client: Callable[[str], Awaitable[RabbitMQRPCClient]],
60-
celery_settings: CelerySettings,
61-
rpc_namespace: RPCNamespace,
62-
) -> AsyncIterator[FastAPI]:
63-
app = FastAPI(
64-
title="master_fastapi_app",
65-
description="Service that manages osparc storage backend",
66-
version="0.0.0",
67-
)
68-
69-
setup_celery_client(app, celery_settings=celery_settings)
70-
rpc_client = await rabbitmq_rpc_client("celery_test_client")
71-
app.state.rabbitmq_rpc_client = rpc_client
72-
73-
async def startup() -> None:
74-
rpc_server = app.state.rabbitmq_rpc_client
75-
assert isinstance(rpc_server, RabbitMQRPCClient)
76-
await rpc_server.register_router(async_jobs_router, rpc_namespace, app)
77-
78-
app.add_event_handler("startup", startup)
79-
80-
async with LifespanManager(
81-
app, startup_timeout=_LIFESPAN_TIMEOUT, shutdown_timeout=_LIFESPAN_TIMEOUT
82-
):
83-
yield app
84-
85-
86-
@pytest.fixture
87-
def register_celery_tasks() -> Callable[[Celery], None]:
88-
"""override if tasks are needed"""
89-
90-
def _(celery_app: Celery) -> None: ...
91-
92-
return _
93-
94-
95-
@pytest.fixture
96-
async def celery_worker_controller(
97-
celery_settings: CelerySettings,
98-
celery_app: Celery,
99-
register_celery_tasks: Callable[[Celery], None],
100-
) -> AsyncIterator[TestWorkController]:
101-
102-
def _create_app() -> FastAPI:
103-
104-
return FastAPI(
105-
title="worker_fastapi_app",
106-
description="Test application for celery_library",
107-
version="0.0.0",
108-
)
109-
110-
def _on_worker_init_wrapper(sender: WorkController, **_kwargs) -> None:
111-
return partial(on_worker_init, _create_app, celery_settings)(sender, **_kwargs)
112-
113-
worker_init.connect(_on_worker_init_wrapper)
114-
worker_shutdown.connect(on_worker_shutdown)
115-
116-
register_celery_tasks(celery_app)
117-
118-
with start_worker(
119-
celery_app,
120-
pool="threads",
121-
concurrency=1,
122-
loglevel="info",
123-
perform_ping_check=False,
124-
queues="default,cpu_bound",
125-
) as worker:
126-
yield worker
127-
128-
129-
@pytest.fixture
130-
def with_storage_celery_worker(
131-
celery_worker_controller: TestWorkController,
132-
) -> CeleryTaskWorker:
133-
assert isinstance(celery_worker_controller.app, Celery)
134-
return get_celery_worker(celery_worker_controller.app)
135-
136-
137-
@pytest.fixture
138-
def user_id(faker: Faker) -> UserID:
139-
return TypeAdapter(UserID).validate_python(faker.pyint(min_value=1, max_value=1000))
140-
141-
142-
@pytest.fixture
143-
def product_name() -> ProductName:
144-
return TypeAdapter(ProductName).validate_python("pytest-product")

0 commit comments

Comments
 (0)