Skip to content

Commit d723594

Browse files
committed
cleanup in storage
1 parent 8a3623f commit d723594

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

packages/service-library/src/servicelib/celery/models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from models_library.api_schemas_rpc_async_jobs.async_jobs import AsyncJobFilter
77
from models_library.progress_bar import ProgressReport
8-
from pydantic import BaseModel, ConfigDict, StringConstraints
8+
from pydantic import BaseModel, StringConstraints
99

1010
TaskID: TypeAlias = str
1111
TaskName: TypeAlias = Annotated[
@@ -15,7 +15,6 @@
1515

1616

1717
class TaskFilter(BaseModel):
18-
model_config = ConfigDict(extra="forbid")
1918

2019
@classmethod
2120
def from_async_job_filter(cls, async_job_filter: AsyncJobFilter) -> "TaskFilter":

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from models_library.projects_nodes_io import LocationID, StorageFileID
2121
from pydantic import AnyUrl, ByteSize, TypeAdapter
2222
from servicelib.aiohttp import status
23-
from servicelib.celery.models import TaskMetadata, TaskUUID
23+
from servicelib.celery.models import TaskFilter, TaskMetadata, TaskUUID
2424
from servicelib.celery.task_manager import TaskManager
2525
from servicelib.logging_utils import log_context
2626
from yarl import URL
@@ -287,17 +287,18 @@ async def complete_upload_file(
287287
# NOTE: completing a multipart upload on AWS can take up to several minutes
288288
# if it returns slow we return a 202 - Accepted, the client will have to check later
289289
# for completeness
290-
async_job_name_data = AsyncJobFilter(
290+
job_filter = AsyncJobFilter(
291291
user_id=query_params.user_id,
292292
product_name=_UNDEFINED_PRODUCT_NAME_FOR_WORKER_TASKS, # NOTE: I would need to change the API here
293293
client_name=_ASYNC_JOB_CLIENT_NAME,
294294
)
295+
task_filter = TaskFilter.from_async_job_filter(job_filter)
295296
task_uuid = await task_manager.submit_task(
296297
TaskMetadata(
297298
name=remote_complete_upload_file.__name__,
298299
),
299-
task_filter=async_job_name_data,
300-
user_id=async_job_name_data.user_id,
300+
task_filter=task_filter,
301+
user_id=job_filter.user_id,
301302
location_id=location_id,
302303
file_id=file_id,
303304
body=body,
@@ -344,19 +345,20 @@ async def is_completed_upload_file(
344345
# therefore we wait a bit to see if it completes fast and return a 204
345346
# if it returns slow we return a 202 - Accepted, the client will have to check later
346347
# for completeness
347-
async_job_name_data = AsyncJobFilter(
348+
job_filter = AsyncJobFilter(
348349
user_id=query_params.user_id,
349350
product_name=_UNDEFINED_PRODUCT_NAME_FOR_WORKER_TASKS, # NOTE: I would need to change the API here
350351
client_name=_ASYNC_JOB_CLIENT_NAME,
351352
)
353+
task_filter = TaskFilter.from_async_job_filter(job_filter)
352354
task_status = await task_manager.get_task_status(
353-
task_filter=async_job_name_data, task_uuid=TaskUUID(future_id)
355+
task_filter=task_filter, task_uuid=TaskUUID(future_id)
354356
)
355357
# first check if the task is in the app
356358
if task_status.is_done:
357359
task_result = TypeAdapter(FileMetaData).validate_python(
358360
await task_manager.get_task_result(
359-
task_filter=async_job_name_data,
361+
task_filter=task_filter,
360362
task_uuid=TaskUUID(future_id),
361363
)
362364
)

services/storage/src/simcore_service_storage/api/rpc/_paths.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
AsyncJobGet,
77
)
88
from models_library.projects_nodes_io import LocationID
9-
from servicelib.celery.models import TaskMetadata
9+
from servicelib.celery.models import TaskFilter, TaskMetadata
1010
from servicelib.celery.task_manager import TaskManager
1111
from servicelib.rabbitmq import RPCRouter
1212

@@ -25,11 +25,12 @@ async def compute_path_size(
2525
path: Path,
2626
) -> AsyncJobGet:
2727
task_name = remote_compute_path_size.__name__
28+
task_filter = TaskFilter.from_async_job_filter(job_filter)
2829
task_uuid = await task_manager.submit_task(
2930
task_metadata=TaskMetadata(
3031
name=task_name,
3132
),
32-
task_filter=job_filter,
33+
task_filter=task_filter,
3334
user_id=job_filter.user_id,
3435
location_id=location_id,
3536
path=path,
@@ -46,11 +47,12 @@ async def delete_paths(
4647
paths: set[Path],
4748
) -> AsyncJobGet:
4849
task_name = remote_delete_paths.__name__
50+
task_filter = TaskFilter.from_async_job_filter(job_filter)
4951
task_uuid = await task_manager.submit_task(
5052
task_metadata=TaskMetadata(
5153
name=task_name,
5254
),
53-
task_filter=job_filter,
55+
task_filter=task_filter,
5456
user_id=job_filter.user_id,
5557
location_id=location_id,
5658
paths=paths,

0 commit comments

Comments
 (0)