Skip to content

Commit 582fbc0

Browse files
committed
updates signature
1 parent 6d7c3a3 commit 582fbc0

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

packages/pytest-simcore/src/pytest_simcore/helpers/webserver_rpc_server.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@
55
# pylint: disable=unused-variable
66

77

8+
from models_library.products import ProductName
89
from models_library.projects import ProjectID
9-
from pydantic import TypeAdapter
10+
from models_library.users import UserID
11+
from pydantic import TypeAdapter, validate_call
1012
from servicelib.rabbitmq._client_rpc import RabbitMQRPCClient
1113

1214

1315
class WebserverRpcSideEffects:
1416
# pylint: disable=no-self-use
1517

18+
@validate_call(config=dict(arbitrary_types_allowed=True))
1619
async def mark_project_as_job(
1720
self,
1821
rpc_client: RabbitMQRPCClient,
1922
*,
23+
product_name: ProductName,
24+
user_id: UserID,
2025
project_uuid: ProjectID,
2126
job_parent_resource_name: str,
2227
) -> None:
@@ -26,4 +31,7 @@ async def mark_project_as_job(
2631
assert "/" in job_parent_resource_name # nosec
2732
assert not job_parent_resource_name.endswith("/") # nosec
2833

34+
assert product_name
35+
assert user_id
36+
2937
TypeAdapter(ProjectID).validate_python(project_uuid)

services/api-server/src/simcore_service_api_server/api/routes/solvers_jobs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ async def create_job(
146146
assert job.name == _compose_job_resource_name(solver_key, version, job.id) # nosec
147147

148148
await wb_api_rpc.mark_project_as_job(
149-
project_uuid=new_project.uuid, job_parent_resource_name=job.runner_name
149+
product_name=product_name,
150+
user_id=user_id,
151+
project_uuid=new_project.uuid,
152+
job_parent_resource_name=job.runner_name,
150153
)
151154

152155
return job

services/api-server/src/simcore_service_api_server/api/routes/studies_jobs.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from ...services_http.webserver import AuthSession
4747
from ...services_rpc.wb_api_server import WbApiRpcClient
4848
from ..dependencies.application import get_reverse_url_mapper
49-
from ..dependencies.authentication import get_current_user_id
49+
from ..dependencies.authentication import get_current_user_id, get_product_name
5050
from ..dependencies.services import get_api_client
5151
from ..dependencies.webserver_http import get_webserver_session
5252
from ..dependencies.webserver_rpc import (
@@ -92,6 +92,8 @@ async def create_study_job(
9292
webserver_api: Annotated[AuthSession, Depends(get_webserver_session)],
9393
wb_api_rpc: Annotated[WbApiRpcClient, Depends(get_wb_api_rpc_client)],
9494
url_for: Annotated[Callable, Depends(get_reverse_url_mapper)],
95+
user_id: Annotated[PositiveInt, Depends(get_current_user_id)],
96+
product_name: Annotated[str, Depends(get_product_name)],
9597
hidden: Annotated[bool, Query()] = True,
9698
x_simcore_parent_project_uuid: ProjectID | None = Header(default=None),
9799
x_simcore_parent_node_id: NodeID | None = Header(default=None),
@@ -126,7 +128,10 @@ async def create_study_job(
126128
)
127129

128130
await wb_api_rpc.mark_project_as_job(
129-
project_uuid=job.id, job_parent_resource_name=job.runner_name
131+
product_name=product_name,
132+
user_id=user_id,
133+
project_uuid=job.id,
134+
job_parent_resource_name=job.runner_name,
130135
)
131136

132137
project_inputs = await webserver_api.get_project_inputs(project_id=project.uuid)

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from fastapi_pagination import create_page
77
from models_library.api_schemas_webserver.licensed_items import LicensedItemRpcGetPage
88
from models_library.licenses import LicensedItemID
9+
from models_library.products import ProductName
910
from models_library.projects import ProjectID
1011
from models_library.resource_tracker_licensed_items_checkouts import (
1112
LicensedItemCheckoutID,
@@ -96,7 +97,7 @@ class WbApiRpcClient(SingletonInAppStateMixin):
9697

9798
@_exception_mapper(rpc_exception_map={})
9899
async def get_licensed_items(
99-
self, *, product_name: str, page_params: PaginationParams
100+
self, *, product_name: ProductName, page_params: PaginationParams
100101
) -> Page[LicensedItemGet]:
101102
licensed_items_page = await _get_licensed_items(
102103
rabbitmq_rpc_client=self._client,
@@ -112,7 +113,7 @@ async def get_licensed_items(
112113
async def get_available_licensed_items_for_wallet(
113114
self,
114115
*,
115-
product_name: str,
116+
product_name: ProductName,
116117
wallet_id: WalletID,
117118
user_id: UserID,
118119
page_params: PaginationParams,
@@ -140,7 +141,7 @@ async def get_available_licensed_items_for_wallet(
140141
async def checkout_licensed_item_for_wallet(
141142
self,
142143
*,
143-
product_name: str,
144+
product_name: ProductName,
144145
user_id: UserID,
145146
wallet_id: WalletID,
146147
licensed_item_id: LicensedItemID,
@@ -177,7 +178,7 @@ async def checkout_licensed_item_for_wallet(
177178
async def release_licensed_item_for_wallet(
178179
self,
179180
*,
180-
product_name: str,
181+
product_name: ProductName,
181182
user_id: UserID,
182183
licensed_item_checkout_id: LicensedItemCheckoutID,
183184
) -> LicensedItemCheckoutGet:
@@ -204,16 +205,16 @@ async def ping(self) -> str:
204205
return await _ping(self._client)
205206

206207
async def mark_project_as_job(
207-
self, project_uuid: ProjectID, job_parent_resource_name: RelativeResourceName
208+
self,
209+
product_name: ProductName,
210+
user_id: UserID,
211+
project_uuid: ProjectID,
212+
job_parent_resource_name: RelativeResourceName,
208213
):
209-
assert not job_parent_resource_name.startswith("/") # nosec
210-
assert "/" in job_parent_resource_name # nosec
211-
assert not job_parent_resource_name.endswith("/") # nosec
212-
213-
assert project_uuid
214-
215214
await projects_rpc.mark_project_as_job(
216215
rpc_client=self._client,
216+
product_name=product_name,
217+
user_id=user_id,
217218
project_uuid=project_uuid,
218219
job_parent_resource_name=job_parent_resource_name,
219220
)

0 commit comments

Comments
 (0)