Skip to content

Commit 7d6d4c9

Browse files
committed
register job pydantic types for serialization - can run function via celery now
1 parent 1400a42 commit 7d6d4c9

File tree

2 files changed

+17
-24
lines changed
  • services/api-server/src/simcore_service_api_server

2 files changed

+17
-24
lines changed

services/api-server/src/simcore_service_api_server/api/dependencies/celery.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,10 @@
44
from celery_library.task_manager import CeleryTaskManager
55
from celery_library.types import register_celery_types, register_pydantic_types
66
from fastapi import FastAPI
7-
from models_library.functions import (
8-
RegisteredProjectFunction,
9-
RegisteredPythonCodeFunction,
10-
RegisteredSolverFunction,
11-
)
127
from servicelib.celery.task_manager import TaskManager
138
from settings_library.celery import CelerySettings
149

15-
from ...api.dependencies.authentication import Identity
16-
from ...models.api_resources import JobLinks
17-
from ...models.schemas.jobs import JobPricingSpecification
10+
from ...celery.worker_tasks.tasks import registered_pydantic_types
1811

1912
ASYNC_JOB_CLIENT_NAME: Final[str] = "API_SERVER"
2013

@@ -26,14 +19,7 @@ async def on_startup() -> None:
2619
)
2720

2821
register_celery_types()
29-
register_pydantic_types(
30-
Identity,
31-
RegisteredProjectFunction,
32-
RegisteredPythonCodeFunction,
33-
RegisteredSolverFunction,
34-
JobPricingSpecification,
35-
JobLinks,
36-
)
22+
register_pydantic_types(*registered_pydantic_types)
3723

3824
app.add_event_handler("startup", on_startup)
3925

services/api-server/src/simcore_service_api_server/celery/worker_tasks/tasks.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
from celery_library.types import register_celery_types, register_pydantic_types
66
from models_library.functions import (
77
RegisteredProjectFunction,
8+
RegisteredProjectFunctionJob,
89
RegisteredPythonCodeFunction,
910
RegisteredSolverFunction,
11+
RegisteredSolverFunctionJob,
1012
)
1113
from servicelib.logging_utils import log_context
1214

@@ -17,17 +19,22 @@
1719

1820
_logger = logging.getLogger(__name__)
1921

22+
registered_pydantic_types = (
23+
Identity,
24+
JobLinks,
25+
JobPricingSpecification,
26+
RegisteredProjectFunction,
27+
RegisteredProjectFunctionJob,
28+
RegisteredPythonCodeFunction,
29+
RegisteredProjectFunctionJob,
30+
RegisteredSolverFunction,
31+
RegisteredSolverFunctionJob,
32+
)
33+
2034

2135
def setup_worker_tasks(app: Celery) -> None:
2236
register_celery_types()
23-
register_pydantic_types(
24-
Identity,
25-
RegisteredProjectFunction,
26-
RegisteredPythonCodeFunction,
27-
RegisteredSolverFunction,
28-
JobPricingSpecification,
29-
JobLinks,
30-
)
37+
register_pydantic_types(*registered_pydantic_types)
3138

3239
with log_context(_logger, logging.INFO, msg="worker task registration"):
3340
register_task(app, run_function)

0 commit comments

Comments
 (0)