Skip to content

Commit 2f5c11a

Browse files
committed
missing files
1 parent 94c26f2 commit 2f5c11a

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

packages/models-library/src/models_library/functions.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from models_library.users import UserID
1414
from models_library.utils.enums import StrAutoEnum
1515
from pydantic import BaseModel, ConfigDict, Field
16+
from servicelib.celery.models import TaskID
1617

1718
from .projects import ProjectID
1819
from .utils.change_case import snake_to_camel
@@ -166,22 +167,40 @@ class RegisteredFunctionJobBase(FunctionJobBase):
166167

167168
class ProjectFunctionJob(FunctionJobBase):
168169
function_class: Literal[FunctionClass.PROJECT] = FunctionClass.PROJECT
169-
project_job_id: ProjectID
170+
project_job_id: ProjectID | None
171+
job_creation_task_id: TaskID | None
170172

171173

172174
class RegisteredProjectFunctionJob(ProjectFunctionJob, RegisteredFunctionJobBase):
173175
pass
174176

175177

178+
class RegisteredProjectFunctionJobPatch(BaseModel):
179+
function_class: FunctionClass
180+
title: str | None
181+
description: str | None
182+
project_job_id: ProjectID | None
183+
job_creation_task_id: TaskID | None
184+
185+
176186
class SolverFunctionJob(FunctionJobBase):
177187
function_class: Literal[FunctionClass.SOLVER] = FunctionClass.SOLVER
178-
solver_job_id: ProjectID
188+
solver_job_id: ProjectID | None
189+
job_creation_task_id: TaskID | None
179190

180191

181192
class RegisteredSolverFunctionJob(SolverFunctionJob, RegisteredFunctionJobBase):
182193
pass
183194

184195

196+
class RegisteredSolverFunctionJobPatch(BaseModel):
197+
function_class: FunctionClass
198+
title: str | None
199+
description: str | None
200+
solver_job_id: ProjectID | None
201+
job_creation_task_id: TaskID | None
202+
203+
185204
class PythonCodeFunctionJob(FunctionJobBase):
186205
function_class: Literal[FunctionClass.PYTHON_CODE] = FunctionClass.PYTHON_CODE
187206

@@ -190,6 +209,12 @@ class RegisteredPythonCodeFunctionJob(PythonCodeFunctionJob, RegisteredFunctionJ
190209
pass
191210

192211

212+
class RegisteredPythonCodeFunctionJobPatch(BaseModel):
213+
function_class: FunctionClass
214+
title: str | None
215+
description: str | None
216+
217+
193218
FunctionJob: TypeAlias = Annotated[
194219
ProjectFunctionJob | PythonCodeFunctionJob | SolverFunctionJob,
195220
Field(discriminator="function_class"),
@@ -202,6 +227,13 @@ class RegisteredPythonCodeFunctionJob(PythonCodeFunctionJob, RegisteredFunctionJ
202227
Field(discriminator="function_class"),
203228
]
204229

230+
RegisteredFunctionJobPatch = Annotated[
231+
RegisteredProjectFunctionJobPatch
232+
| RegisteredPythonCodeFunctionJobPatch
233+
| RegisteredSolverFunctionJobPatch,
234+
Field(discriminator="function_class"),
235+
]
236+
205237

206238
class FunctionJobStatus(BaseModel):
207239
status: str

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/webserver/functions/functions_rpc_interface.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
FunctionOutputs,
2323
FunctionUserAccessRights,
2424
FunctionUserApiAccessRights,
25+
RegisteredFunctionJobPatch,
2526
)
2627
from models_library.products import ProductName
2728
from models_library.rabbitmq_basic_types import RPCMethodName
@@ -297,6 +298,28 @@ async def register_function_job(
297298
) # Validates the result as a RegisteredFunctionJob
298299

299300

301+
@log_decorator(_logger, level=logging.DEBUG)
302+
async def patch_registered_function_job(
303+
rabbitmq_rpc_client: RabbitMQRPCClient,
304+
*,
305+
user_id: UserID,
306+
product_name: ProductName,
307+
function_job_uuid: FunctionJobID,
308+
registered_function_job_patch: RegisteredFunctionJobPatch,
309+
) -> RegisteredFunctionJob:
310+
result = await rabbitmq_rpc_client.request(
311+
WEBSERVER_RPC_NAMESPACE,
312+
TypeAdapter(RPCMethodName).validate_python("patch_registered_function_job"),
313+
user_id=user_id,
314+
product_name=product_name,
315+
function_job_uuid=function_job_uuid,
316+
registered_function_job_patch=registered_function_job_patch,
317+
)
318+
return TypeAdapter(RegisteredFunctionJob).validate_python(
319+
result
320+
) # Validates the result as a RegisteredFunctionJob
321+
322+
300323
@log_decorator(_logger, level=logging.DEBUG)
301324
async def get_function_job(
302325
rabbitmq_rpc_client: RabbitMQRPCClient,

services/api-server/src/simcore_service_api_server/_service_function_jobs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ async def run_function(
242242
inputs=joined_inputs,
243243
outputs=None,
244244
project_job_id=study_job.id,
245+
job_creation_task_id=None,
245246
),
246247
user_id=self.user_id,
247248
product_name=self.product_name,
@@ -271,6 +272,7 @@ async def run_function(
271272
inputs=joined_inputs,
272273
outputs=None,
273274
solver_job_id=solver_job.id,
275+
job_creation_task_id=None,
274276
),
275277
user_id=self.user_id,
276278
product_name=self.product_name,

services/api-server/tests/unit/api_functions/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def mock_project_function_job(
180180
"outputs": None,
181181
"project_job_id": f"{uuid4()}",
182182
"function_class": FunctionClass.PROJECT,
183+
"job_creation_task_id": None,
183184
}
184185
return ProjectFunctionJob(**mock_function_job)
185186

@@ -209,6 +210,7 @@ def mock_solver_function_job(
209210
outputs=None,
210211
function_class=FunctionClass.SOLVER,
211212
solver_job_id=ProjectID(f"{uuid4()}"),
213+
job_creation_task_id=None,
212214
)
213215

214216

0 commit comments

Comments
 (0)