Skip to content

Commit 4f4b1f5

Browse files
committed
correct wrong usage of client_app_name
1 parent 59fe947 commit 4f4b1f5

File tree

7 files changed

+54
-55
lines changed

7 files changed

+54
-55
lines changed

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/storage/_utils.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/storage/paths.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,21 @@
55
AsyncJobGet,
66
)
77
from models_library.api_schemas_storage import STORAGE_RPC_NAMESPACE
8-
from models_library.products import ProductName
98
from models_library.projects_nodes_io import LocationID
109
from models_library.rabbitmq_basic_types import RPCMethodName
11-
from models_library.users import UserID
1210
from pydantic import TypeAdapter
1311

1412
from ..._client_rpc import RabbitMQRPCClient
1513
from ..async_jobs.async_jobs import submit
16-
from ._utils import get_async_job_filter
1714

1815

1916
async def compute_path_size(
2017
client: RabbitMQRPCClient,
2118
*,
22-
user_id: UserID,
23-
product_name: ProductName,
2419
location_id: LocationID,
2520
path: Path,
21+
job_filter: AsyncJobFilter,
2622
) -> tuple[AsyncJobGet, AsyncJobFilter]:
27-
job_filter = get_async_job_filter(user_id=user_id, product_name=product_name)
2823
async_job_rpc_get = await submit(
2924
rabbitmq_rpc_client=client,
3025
rpc_namespace=STORAGE_RPC_NAMESPACE,
@@ -39,12 +34,10 @@ async def compute_path_size(
3934
async def delete_paths(
4035
client: RabbitMQRPCClient,
4136
*,
42-
user_id: UserID,
43-
product_name: ProductName,
4437
location_id: LocationID,
4538
paths: set[Path],
39+
job_filter: AsyncJobFilter,
4640
) -> tuple[AsyncJobGet, AsyncJobFilter]:
47-
job_filter = get_async_job_filter(user_id=user_id, product_name=product_name)
4841
async_job_rpc_get = await submit(
4942
rabbitmq_rpc_client=client,
5043
rpc_namespace=STORAGE_RPC_NAMESPACE,

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/storage/simcore_s3.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,16 @@
77
from models_library.api_schemas_storage import STORAGE_RPC_NAMESPACE
88
from models_library.api_schemas_storage.storage_schemas import FoldersBody
99
from models_library.api_schemas_webserver.storage import PathToExport
10-
from models_library.products import ProductName
1110
from models_library.rabbitmq_basic_types import RPCMethodName
12-
from models_library.users import UserID
1311
from pydantic import TypeAdapter
1412

1513
from ... import RabbitMQRPCClient
1614
from ..async_jobs.async_jobs import submit
17-
from ._utils import get_async_job_filter
1815

1916

2017
async def copy_folders_from_project(
21-
client: RabbitMQRPCClient,
22-
*,
23-
user_id: UserID,
24-
product_name: ProductName,
25-
body: FoldersBody,
18+
client: RabbitMQRPCClient, *, body: FoldersBody, job_filter: AsyncJobFilter
2619
) -> tuple[AsyncJobGet, AsyncJobFilter]:
27-
job_filter = get_async_job_filter(user_id=user_id, product_name=product_name)
2820
async_job_rpc_get = await submit(
2921
rabbitmq_rpc_client=client,
3022
rpc_namespace=STORAGE_RPC_NAMESPACE,
@@ -40,12 +32,10 @@ async def copy_folders_from_project(
4032
async def start_export_data(
4133
rabbitmq_rpc_client: RabbitMQRPCClient,
4234
*,
43-
user_id: UserID,
44-
product_name: ProductName,
4535
paths_to_export: list[PathToExport],
4636
export_as: Literal["path", "download_link"],
37+
job_filter: AsyncJobFilter
4738
) -> tuple[AsyncJobGet, AsyncJobFilter]:
48-
job_filter = get_async_job_filter(user_id=user_id, product_name=product_name)
4939
async_job_rpc_get = await submit(
5040
rabbitmq_rpc_client,
5141
rpc_namespace=STORAGE_RPC_NAMESPACE,

services/api-server/src/simcore_service_api_server/services_rpc/storage.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
from dataclasses import dataclass
22
from functools import partial
33

4-
from models_library.api_schemas_rpc_async_jobs.async_jobs import AsyncJobGet
4+
from models_library.api_schemas_rpc_async_jobs.async_jobs import (
5+
AsyncJobFilter,
6+
AsyncJobGet,
7+
)
58
from models_library.api_schemas_webserver.storage import PathToExport
69
from models_library.products import ProductName
710
from models_library.users import UserID
811
from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient
912
from servicelib.rabbitmq.rpc_interfaces.storage import simcore_s3 as storage_rpc
1013

14+
from ..api.dependencies.celery import ASYNC_JOB_CLIENT_NAME
1115
from ..exceptions.service_errors_utils import service_exception_mapper
1216

1317
_exception_mapper = partial(service_exception_mapper, service_name="Storage")
@@ -26,9 +30,12 @@ async def start_data_export(
2630
) -> AsyncJobGet:
2731
async_job_get, _ = await storage_rpc.start_export_data(
2832
self._rpc_client,
29-
user_id=self._user_id,
30-
product_name=self._product_name,
3133
paths_to_export=paths_to_export,
3234
export_as="download_link",
35+
job_filter=AsyncJobFilter(
36+
user_id=self._user_id,
37+
product_name=self._product_name,
38+
client_name=ASYNC_JOB_CLIENT_NAME,
39+
),
3340
)
3441
return async_job_get

services/storage/tests/unit/test_rpc_handlers_paths.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ async def _assert_compute_path_size(
7171
) -> ByteSize:
7272
async_job, async_job_name = await compute_path_size(
7373
storage_rpc_client,
74-
product_name=product_name,
75-
user_id=user_id,
7674
location_id=location_id,
7775
path=path,
76+
job_filter=AsyncJobFilter(
77+
user_id=user_id, product_name=product_name, client_name="PYTEST_CLIENT_NAME"
78+
),
7879
)
7980
async for job_composed_result in wait_and_get_result(
8081
storage_rpc_client,
@@ -107,10 +108,11 @@ async def _assert_delete_paths(
107108
) -> None:
108109
async_job, async_job_name = await delete_paths(
109110
storage_rpc_client,
110-
product_name=product_name,
111-
user_id=user_id,
112111
location_id=location_id,
113112
paths=paths,
113+
job_filter=AsyncJobFilter(
114+
user_id=user_id, product_name=product_name, client_name="PYTEST_CLIENT_NAME"
115+
),
114116
)
115117
async for job_composed_result in wait_and_get_result(
116118
storage_rpc_client,

services/storage/tests/unit/test_rpc_handlers_simcore_s3.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
from faker import Faker
2525
from fastapi import FastAPI
2626
from fastapi.encoders import jsonable_encoder
27-
from models_library.api_schemas_rpc_async_jobs.async_jobs import AsyncJobResult
27+
from models_library.api_schemas_rpc_async_jobs.async_jobs import (
28+
AsyncJobFilter,
29+
AsyncJobResult,
30+
)
2831
from models_library.api_schemas_rpc_async_jobs.exceptions import JobError
2932
from models_library.api_schemas_storage import STORAGE_RPC_NAMESPACE
3033
from models_library.api_schemas_storage.storage_schemas import (
@@ -84,11 +87,14 @@ async def _request_copy_folders(
8487
) as ctx:
8588
async_job_get, async_job_name = await copy_folders_from_project(
8689
rpc_client,
87-
user_id=user_id,
88-
product_name=product_name,
8990
body=FoldersBody(
9091
source=source_project, destination=dst_project, nodes_map=nodes_map
9192
),
93+
job_filter=AsyncJobFilter(
94+
user_id=user_id,
95+
product_name=product_name,
96+
client_name="PYTEST_CLIENT_NAME",
97+
),
9298
)
9399

94100
async for async_job_result in wait_and_get_result(
@@ -526,10 +532,13 @@ async def _request_start_export_data(
526532
) as ctx:
527533
async_job_get, async_job_name = await start_export_data(
528534
rpc_client,
529-
user_id=user_id,
530-
product_name=product_name,
531535
paths_to_export=paths_to_export,
532536
export_as=export_as,
537+
job_filter=AsyncJobFilter(
538+
user_id=user_id,
539+
product_name=product_name,
540+
client_name="PYTEST_CLIENT_NAME",
541+
),
533542
)
534543

535544
async for async_job_result in wait_and_get_result(

services/web/server/src/simcore_service_webserver/storage/_rest.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
from models_library.api_schemas_long_running_tasks.tasks import (
1313
TaskGet,
1414
)
15-
from models_library.api_schemas_rpc_async_jobs.async_jobs import AsyncJobGet
15+
from models_library.api_schemas_rpc_async_jobs.async_jobs import (
16+
AsyncJobFilter,
17+
AsyncJobGet,
18+
)
1619
from models_library.api_schemas_storage.storage_schemas import (
1720
FileUploadCompleteResponse,
1821
FileUploadCompletionBody,
@@ -47,6 +50,7 @@
4750
from servicelib.rabbitmq.rpc_interfaces.storage.simcore_s3 import start_export_data
4851
from servicelib.request_keys import RQT_USERID_KEY
4952
from servicelib.rest_responses import unwrap_envelope
53+
from simcore_service_webserver.constants import ASYNC_JOB_CLIENT_NAME
5054
from yarl import URL
5155

5256
from .._meta import API_VTAG
@@ -206,10 +210,13 @@ async def compute_path_size(request: web.Request) -> web.Response:
206210
rabbitmq_rpc_client = get_rabbitmq_rpc_client(request.app)
207211
async_job, _ = await remote_compute_path_size(
208212
rabbitmq_rpc_client,
209-
user_id=req_ctx.user_id,
210-
product_name=req_ctx.product_name,
211213
location_id=path_params.location_id,
212214
path=path_params.path,
215+
job_filter=AsyncJobFilter(
216+
user_id=req_ctx.user_id,
217+
product_name=req_ctx.product_name,
218+
client_name=ASYNC_JOB_CLIENT_NAME,
219+
),
213220
)
214221

215222
return _create_data_response_from_async_job(request, async_job)
@@ -229,10 +236,13 @@ async def batch_delete_paths(request: web.Request):
229236
rabbitmq_rpc_client = get_rabbitmq_rpc_client(request.app)
230237
async_job, _ = await remote_delete_paths(
231238
rabbitmq_rpc_client,
232-
user_id=req_ctx.user_id,
233-
product_name=req_ctx.product_name,
234239
location_id=path_params.location_id,
235240
paths=body.paths,
241+
job_filter=AsyncJobFilter(
242+
user_id=req_ctx.user_id,
243+
product_name=req_ctx.product_name,
244+
client_name=ASYNC_JOB_CLIENT_NAME,
245+
),
236246
)
237247
return _create_data_response_from_async_job(request, async_job)
238248

@@ -494,10 +504,13 @@ def allow_only_simcore(cls, v: int) -> int:
494504
)
495505
async_job_rpc_get, _ = await start_export_data(
496506
rabbitmq_rpc_client=rabbitmq_rpc_client,
497-
user_id=_req_ctx.user_id,
498-
product_name=_req_ctx.product_name,
499507
paths_to_export=export_data_post.paths,
500508
export_as="path",
509+
job_filter=AsyncJobFilter(
510+
user_id=_req_ctx.user_id,
511+
product_name=_req_ctx.product_name,
512+
client_name=ASYNC_JOB_CLIENT_NAME,
513+
),
501514
)
502515
_job_id = f"{async_job_rpc_get.job_id}"
503516
return create_data_response(

0 commit comments

Comments
 (0)