Skip to content

Commit 2405161

Browse files
remove pydantic
1 parent 6de9a83 commit 2405161

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

packages/celery-library/src/celery_library/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async def submit_task(
5454
self._celery_app.send_task(
5555
task_metadata.name,
5656
task_id=task_id,
57-
kwargs=task_params,
57+
kwargs={"task_id": task_id} | task_params,
5858
queue=task_metadata.queue.value,
5959
)
6060

packages/celery-library/src/celery_library/task.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ class TaskAbortedError(Exception): ...
4040
def _async_task_wrapper(
4141
app: Celery,
4242
) -> Callable[
43-
[Callable[Concatenate[AbortableTask, TaskId, P], Coroutine[Any, Any, R]]],
43+
[Callable[Concatenate[AbortableTask, P], Coroutine[Any, Any, R]]],
4444
Callable[Concatenate[AbortableTask, P], R],
4545
]:
4646
def decorator(
47-
coro: Callable[Concatenate[AbortableTask, TaskId, P], Coroutine[Any, Any, R]],
47+
coro: Callable[Concatenate[AbortableTask, P], Coroutine[Any, Any, R]],
4848
) -> Callable[Concatenate[AbortableTask, P], R]:
4949
@wraps(coro)
5050
def wrapper(task: AbortableTask, *args: P.args, **kwargs: P.kwargs) -> R:
@@ -56,7 +56,7 @@ async def run_task(task_id: TaskID) -> R:
5656
try:
5757
async with asyncio.TaskGroup() as tg:
5858
main_task = tg.create_task(
59-
coro(task, task_id, *args, **kwargs),
59+
coro(task, *args, **kwargs),
6060
)
6161

6262
async def abort_monitor():
@@ -205,4 +205,5 @@ def register_task( # type: ignore[misc]
205205
bind=True,
206206
base=AbortableTask,
207207
time_limit=None if timeout is None else timeout.total_seconds(),
208+
pydantic=True,
208209
)(wrapped_fn)

services/storage/src/simcore_service_storage/api/_worker_tasks/tasks.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,10 @@
22

33
from celery import Celery # type: ignore[import-untyped]
44
from celery_library.task import register_task
5-
from celery_library.types import register_celery_types, register_pydantic_types
5+
from celery_library.types import register_celery_types
66
from models_library.api_schemas_storage.export_data_async_jobs import AccessRightError
7-
from models_library.api_schemas_storage.storage_schemas import (
8-
FileUploadCompletionBody,
9-
FoldersBody,
10-
)
117
from servicelib.logging_utils import log_context
128

13-
from ...models import FileMetaData
149
from ._files import complete_upload_file
1510
from ._paths import compute_path_size, delete_paths
1611
from ._simcore_s3 import deep_copy_files_from_project, export_data
@@ -21,8 +16,6 @@
2116
def setup_worker_tasks(app: Celery) -> None:
2217
register_celery_types()
2318

24-
register_pydantic_types(FileUploadCompletionBody, FileMetaData, FoldersBody)
25-
2619
with log_context(_logger, logging.INFO, msg="worker task registration"):
2720
register_task(app, export_data, dont_autoretry_for=(AccessRightError,))
2821
register_task(app, compute_path_size)

services/storage/src/simcore_service_storage/api/rest/_files.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ async def complete_upload_file(
292292
user_id=async_job_name_data.user_id,
293293
location_id=location_id,
294294
file_id=file_id,
295-
body=body,
295+
body=body.model_dump(),
296296
)
297297

298298
route = (
@@ -353,7 +353,8 @@ async def is_completed_upload_file(
353353
assert new_fmd.location_id == location_id # nosec
354354
assert new_fmd.file_id == file_id # nosec
355355
response = FileUploadCompleteFutureResponse(
356-
state=FileUploadCompleteState.OK, e_tag=new_fmd.entity_tag
356+
state=FileUploadCompleteState.OK,
357+
e_tag=FileMetaData.model_validate(new_fmd).entity_tag,
357358
)
358359
else:
359360
# the task is still running

0 commit comments

Comments
 (0)