Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions services/api-server/openapi.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"openapi": "3.1.0",
"info": {
Expand Down Expand Up @@ -7585,6 +7585,42 @@
"format": "uuid",
"title": "Function Id"
}
},
{
"name": "x-simcore-parent-project-uuid",
"in": "header",
"required": true,
"schema": {
"anyOf": [
{
"type": "string",
"format": "uuid"
},
{
"type": "string",
"pattern": "^null$"
}
],
"title": "X-Simcore-Parent-Project-Uuid"
}
},
{
"name": "x-simcore-parent-node-id",
"in": "header",
"required": true,
"schema": {
"anyOf": [
{
"type": "string",
"format": "uuid"
},
{
"type": "string",
"pattern": "^null$"
}
],
"title": "X-Simcore-Parent-Node-Id"
}
}
],
"requestBody": {
Expand Down Expand Up @@ -7681,6 +7717,42 @@
"format": "uuid",
"title": "Function Id"
}
},
{
"name": "x-simcore-parent-project-uuid",
"in": "header",
"required": true,
"schema": {
"anyOf": [
{
"type": "string",
"format": "uuid"
},
{
"type": "string",
"pattern": "^null$"
}
],
"title": "X-Simcore-Parent-Project-Uuid"
}
},
{
"name": "x-simcore-parent-node-id",
"in": "header",
"required": true,
"schema": {
"anyOf": [
{
"type": "string",
"format": "uuid"
},
{
"type": "string",
"pattern": "^null$"
}
],
"title": "X-Simcore-Parent-Node-Id"
}
}
],
"requestBody": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from collections.abc import Callable
from typing import Annotated, Final
from typing import Annotated, Final, TypeAlias

import jsonschema
from fastapi import APIRouter, Depends, Request, status
from fastapi import APIRouter, Depends, Header, Request, status
from fastapi_pagination.api import create_page
from jsonschema import ValidationError
from models_library.api_schemas_api_server.functions import (
Expand All @@ -29,8 +29,11 @@
UnsupportedFunctionClassError,
)
from models_library.products import ProductName
from models_library.projects import ProjectID
from models_library.projects_nodes_io import NodeID
from models_library.projects_state import RunningState
from models_library.users import UserID
from pydantic import StringConstraints
from servicelib.fastapi.dependencies import get_reverse_url_mapper
from simcore_service_api_server._service_jobs import JobService

Expand All @@ -56,6 +59,8 @@
# pylint: disable=too-many-arguments
# pylint: disable=cyclic-import

NullString: TypeAlias = Annotated[str, StringConstraints(pattern="^null$")]

function_router = APIRouter()

_COMMON_FUNCTION_ERROR_RESPONSES: Final[dict] = {
Expand Down Expand Up @@ -372,8 +377,21 @@ async def run_function( # noqa: PLR0913
product_name: Annotated[str, Depends(get_product_name)],
solver_service: Annotated[SolverService, Depends(get_solver_service)],
job_service: Annotated[JobService, Depends(get_job_service)],
x_simcore_parent_project_uuid: Annotated[ProjectID | NullString, Header()],
x_simcore_parent_node_id: Annotated[NodeID | NullString, Header()],
) -> RegisteredFunctionJob:

parent_project_uuid = (
x_simcore_parent_project_uuid
if isinstance(x_simcore_parent_project_uuid, ProjectID)
else None
)
parent_node_id = (
x_simcore_parent_node_id
if isinstance(x_simcore_parent_node_id, NodeID)
else None
)

# Make sure the user is allowed to execute any function
# (read/write right is checked in the other endpoint called in this method)
user_api_access_rights = await wb_api_rpc.get_functions_user_api_access_rights(
Expand Down Expand Up @@ -443,8 +461,8 @@ async def run_function( # noqa: PLR0913
webserver_api=webserver_api,
wb_api_rpc=wb_api_rpc,
url_for=url_for,
x_simcore_parent_project_uuid=None,
x_simcore_parent_node_id=None,
x_simcore_parent_project_uuid=parent_project_uuid,
x_simcore_parent_node_id=parent_node_id,
user_id=user_id,
product_name=product_name,
)
Expand Down Expand Up @@ -478,8 +496,8 @@ async def run_function( # noqa: PLR0913
solver_service=solver_service,
job_service=job_service,
url_for=url_for,
x_simcore_parent_project_uuid=None,
x_simcore_parent_node_id=None,
x_simcore_parent_project_uuid=parent_project_uuid,
x_simcore_parent_node_id=parent_node_id,
)
await solvers_jobs.start_job(
request=request,
Expand Down Expand Up @@ -558,6 +576,8 @@ async def map_function( # noqa: PLR0913
product_name: Annotated[str, Depends(get_product_name)],
solver_service: Annotated[SolverService, Depends(get_solver_service)],
job_service: Annotated[JobService, Depends(get_job_service)],
x_simcore_parent_project_uuid: Annotated[ProjectID | NullString, Header()],
x_simcore_parent_node_id: Annotated[NodeID | NullString, Header()],
) -> RegisteredFunctionJobCollection:
function_jobs = []
function_jobs = [
Expand All @@ -573,6 +593,8 @@ async def map_function( # noqa: PLR0913
request=request,
solver_service=solver_service,
job_service=job_service,
x_simcore_parent_project_uuid=x_simcore_parent_project_uuid,
x_simcore_parent_node_id=x_simcore_parent_node_id,
)
for function_inputs in function_inputs_list
]
Expand Down
Loading
Loading