Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
174 changes: 87 additions & 87 deletions services/api-server/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -5567,7 +5567,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Page_Union_Annotated_Union_RegisteredProjectFunctionJobWithStatus__RegisteredPythonCodeFunctionJobWithStatus__RegisteredSolverFunctionJobWithStatus___FieldInfo_annotation_NoneType__required_True__discriminator__function_class_____Annotated_Union_RegisteredProjectFunctionJob__RegisteredPythonCodeFunctionJob__RegisteredSolverFunctionJob___FieldInfo_annotation_NoneType__required_True__discriminator__function_class_____"
"$ref": "#/components/schemas/PageRegisteredFunctionJobWithorWithoutStatus"
}
}
}
Expand Down Expand Up @@ -9946,29 +9946,54 @@
],
"title": "OnePage[StudyPort]"
},
"Page_Annotated_Union_RegisteredProjectFunctionJob__RegisteredPythonCodeFunctionJob__RegisteredSolverFunctionJob___FieldInfo_annotation_NoneType__required_True__discriminator__function_class____": {
"PageRegisteredFunctionJobWithorWithoutStatus": {
"properties": {
"items": {
"items": {
"oneOf": [
{
"$ref": "#/components/schemas/RegisteredProjectFunctionJob"
},
"anyOf": [
{
"$ref": "#/components/schemas/RegisteredPythonCodeFunctionJob"
"oneOf": [
{
"$ref": "#/components/schemas/RegisteredProjectFunctionJobWithStatus"
},
{
"$ref": "#/components/schemas/RegisteredPythonCodeFunctionJobWithStatus"
},
{
"$ref": "#/components/schemas/RegisteredSolverFunctionJobWithStatus"
}
],
"discriminator": {
"propertyName": "function_class",
"mapping": {
"PROJECT": "#/components/schemas/RegisteredProjectFunctionJobWithStatus",
"PYTHON_CODE": "#/components/schemas/RegisteredPythonCodeFunctionJobWithStatus",
"SOLVER": "#/components/schemas/RegisteredSolverFunctionJobWithStatus"
}
}
},
{
"$ref": "#/components/schemas/RegisteredSolverFunctionJob"
}
],
"discriminator": {
"propertyName": "function_class",
"mapping": {
"PROJECT": "#/components/schemas/RegisteredProjectFunctionJob",
"PYTHON_CODE": "#/components/schemas/RegisteredPythonCodeFunctionJob",
"SOLVER": "#/components/schemas/RegisteredSolverFunctionJob"
"oneOf": [
{
"$ref": "#/components/schemas/RegisteredProjectFunctionJob"
},
{
"$ref": "#/components/schemas/RegisteredPythonCodeFunctionJob"
},
{
"$ref": "#/components/schemas/RegisteredSolverFunctionJob"
}
],
"discriminator": {
"propertyName": "function_class",
"mapping": {
"PROJECT": "#/components/schemas/RegisteredProjectFunctionJob",
"PYTHON_CODE": "#/components/schemas/RegisteredPythonCodeFunctionJob",
"SOLVER": "#/components/schemas/RegisteredSolverFunctionJob"
}
}
}
}
]
},
"type": "array",
"title": "Items"
Expand Down Expand Up @@ -10021,29 +10046,29 @@
"offset",
"links"
],
"title": "Page[Annotated[Union[RegisteredProjectFunctionJob, RegisteredPythonCodeFunctionJob, RegisteredSolverFunctionJob], FieldInfo(annotation=NoneType, required=True, discriminator='function_class')]]"
"title": "PageRegisteredFunctionJobWithorWithoutStatus"
},
"Page_Annotated_Union_RegisteredProjectFunction__RegisteredPythonCodeFunction__RegisteredSolverFunction___FieldInfo_annotation_NoneType__required_True__discriminator__function_class____": {
"Page_Annotated_Union_RegisteredProjectFunctionJob__RegisteredPythonCodeFunctionJob__RegisteredSolverFunctionJob___FieldInfo_annotation_NoneType__required_True__discriminator__function_class____": {
"properties": {
"items": {
"items": {
"oneOf": [
{
"$ref": "#/components/schemas/RegisteredProjectFunction"
"$ref": "#/components/schemas/RegisteredProjectFunctionJob"
},
{
"$ref": "#/components/schemas/RegisteredPythonCodeFunction"
"$ref": "#/components/schemas/RegisteredPythonCodeFunctionJob"
},
{
"$ref": "#/components/schemas/RegisteredSolverFunction"
"$ref": "#/components/schemas/RegisteredSolverFunctionJob"
}
],
"discriminator": {
"propertyName": "function_class",
"mapping": {
"PROJECT": "#/components/schemas/RegisteredProjectFunction",
"PYTHON_CODE": "#/components/schemas/RegisteredPythonCodeFunction",
"SOLVER": "#/components/schemas/RegisteredSolverFunction"
"PROJECT": "#/components/schemas/RegisteredProjectFunctionJob",
"PYTHON_CODE": "#/components/schemas/RegisteredPythonCodeFunctionJob",
"SOLVER": "#/components/schemas/RegisteredSolverFunctionJob"
}
}
},
Expand Down Expand Up @@ -10098,13 +10123,31 @@
"offset",
"links"
],
"title": "Page[Annotated[Union[RegisteredProjectFunction, RegisteredPythonCodeFunction, RegisteredSolverFunction], FieldInfo(annotation=NoneType, required=True, discriminator='function_class')]]"
"title": "Page[Annotated[Union[RegisteredProjectFunctionJob, RegisteredPythonCodeFunctionJob, RegisteredSolverFunctionJob], FieldInfo(annotation=NoneType, required=True, discriminator='function_class')]]"
},
"Page_File_": {
"Page_Annotated_Union_RegisteredProjectFunction__RegisteredPythonCodeFunction__RegisteredSolverFunction___FieldInfo_annotation_NoneType__required_True__discriminator__function_class____": {
"properties": {
"items": {
"items": {
"$ref": "#/components/schemas/File"
"oneOf": [
{
"$ref": "#/components/schemas/RegisteredProjectFunction"
},
{
"$ref": "#/components/schemas/RegisteredPythonCodeFunction"
},
{
"$ref": "#/components/schemas/RegisteredSolverFunction"
}
],
"discriminator": {
"propertyName": "function_class",
"mapping": {
"PROJECT": "#/components/schemas/RegisteredProjectFunction",
"PYTHON_CODE": "#/components/schemas/RegisteredPythonCodeFunction",
"SOLVER": "#/components/schemas/RegisteredSolverFunction"
}
}
},
"type": "array",
"title": "Items"
Expand Down Expand Up @@ -10157,13 +10200,13 @@
"offset",
"links"
],
"title": "Page[File]"
"title": "Page[Annotated[Union[RegisteredProjectFunction, RegisteredPythonCodeFunction, RegisteredSolverFunction], FieldInfo(annotation=NoneType, required=True, discriminator='function_class')]]"
},
"Page_Job_": {
"Page_File_": {
"properties": {
"items": {
"items": {
"$ref": "#/components/schemas/Job"
"$ref": "#/components/schemas/File"
},
"type": "array",
"title": "Items"
Expand Down Expand Up @@ -10216,13 +10259,13 @@
"offset",
"links"
],
"title": "Page[Job]"
"title": "Page[File]"
},
"Page_LicensedItemGet_": {
"Page_Job_": {
"properties": {
"items": {
"items": {
"$ref": "#/components/schemas/LicensedItemGet"
"$ref": "#/components/schemas/Job"
},
"type": "array",
"title": "Items"
Expand Down Expand Up @@ -10275,13 +10318,13 @@
"offset",
"links"
],
"title": "Page[LicensedItemGet]"
"title": "Page[Job]"
},
"Page_RegisteredFunctionJobCollection_": {
"Page_LicensedItemGet_": {
"properties": {
"items": {
"items": {
"$ref": "#/components/schemas/RegisteredFunctionJobCollection"
"$ref": "#/components/schemas/LicensedItemGet"
},
"type": "array",
"title": "Items"
Expand Down Expand Up @@ -10334,13 +10377,13 @@
"offset",
"links"
],
"title": "Page[RegisteredFunctionJobCollection]"
"title": "Page[LicensedItemGet]"
},
"Page_Study_": {
"Page_RegisteredFunctionJobCollection_": {
"properties": {
"items": {
"items": {
"$ref": "#/components/schemas/Study"
"$ref": "#/components/schemas/RegisteredFunctionJobCollection"
},
"type": "array",
"title": "Items"
Expand Down Expand Up @@ -10393,56 +10436,13 @@
"offset",
"links"
],
"title": "Page[Study]"
"title": "Page[RegisteredFunctionJobCollection]"
},
"Page_Union_Annotated_Union_RegisteredProjectFunctionJobWithStatus__RegisteredPythonCodeFunctionJobWithStatus__RegisteredSolverFunctionJobWithStatus___FieldInfo_annotation_NoneType__required_True__discriminator__function_class_____Annotated_Union_RegisteredProjectFunctionJob__RegisteredPythonCodeFunctionJob__RegisteredSolverFunctionJob___FieldInfo_annotation_NoneType__required_True__discriminator__function_class_____": {
"Page_Study_": {
"properties": {
"items": {
"items": {
"anyOf": [
{
"oneOf": [
{
"$ref": "#/components/schemas/RegisteredProjectFunctionJobWithStatus"
},
{
"$ref": "#/components/schemas/RegisteredPythonCodeFunctionJobWithStatus"
},
{
"$ref": "#/components/schemas/RegisteredSolverFunctionJobWithStatus"
}
],
"discriminator": {
"propertyName": "function_class",
"mapping": {
"PROJECT": "#/components/schemas/RegisteredProjectFunctionJobWithStatus",
"PYTHON_CODE": "#/components/schemas/RegisteredPythonCodeFunctionJobWithStatus",
"SOLVER": "#/components/schemas/RegisteredSolverFunctionJobWithStatus"
}
}
},
{
"oneOf": [
{
"$ref": "#/components/schemas/RegisteredProjectFunctionJob"
},
{
"$ref": "#/components/schemas/RegisteredPythonCodeFunctionJob"
},
{
"$ref": "#/components/schemas/RegisteredSolverFunctionJob"
}
],
"discriminator": {
"propertyName": "function_class",
"mapping": {
"PROJECT": "#/components/schemas/RegisteredProjectFunctionJob",
"PYTHON_CODE": "#/components/schemas/RegisteredPythonCodeFunctionJob",
"SOLVER": "#/components/schemas/RegisteredSolverFunctionJob"
}
}
}
]
"$ref": "#/components/schemas/Study"
},
"type": "array",
"title": "Items"
Expand Down Expand Up @@ -10495,7 +10495,7 @@
"offset",
"links"
],
"title": "Page[Union[Annotated[Union[RegisteredProjectFunctionJobWithStatus, RegisteredPythonCodeFunctionJobWithStatus, RegisteredSolverFunctionJobWithStatus], FieldInfo(annotation=NoneType, required=True, discriminator='function_class')], Annotated[Union[RegisteredProjectFunctionJob, RegisteredPythonCodeFunctionJob, RegisteredSolverFunctionJob], FieldInfo(annotation=NoneType, required=True, discriminator='function_class')]]]"
"title": "Page[Study]"
},
"PricingPlanClassification": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections.abc import Sequence
from logging import getLogger
from typing import Annotated, Final

Expand All @@ -14,7 +13,7 @@
FunctionOutputs,
RegisteredFunctionJob,
)
from models_library.functions import RegisteredFunction, RegisteredFunctionJobWithStatus
from models_library.functions import RegisteredFunction
from models_library.functions_errors import (
UnsupportedFunctionClassError,
UnsupportedFunctionFunctionJobClassCombinationError,
Expand All @@ -31,7 +30,8 @@
from ..._service_functions import FunctionService
from ..._service_jobs import JobService
from ...exceptions.function_errors import FunctionJobProjectMissingError
from ...models.pagination import Page, PaginationParams
from ...models.domain.functions import PageRegisteredFunctionJobWithorWithoutStatus
from ...models.pagination import PaginationParams
from ...models.schemas.errors import ErrorGet
from ...models.schemas.functions_filters import FunctionJobsListFilters
from ...services_rpc.wb_api_server import WbApiRpcClient
Expand Down Expand Up @@ -116,9 +116,7 @@

@function_job_router.get(
"",
response_model=Page[
RegisteredFunctionJobWithStatus | RegisteredFunctionJob
], # left-right order is important here
response_model=PageRegisteredFunctionJobWithorWithoutStatus,
description=create_route_description(
base="List function jobs", changelog=CHANGE_LOGS["list_function_jobs"]
),
Expand All @@ -138,11 +136,8 @@ async def list_function_jobs(
bool, Query(description="Include job status in response")
] = False,
):
function_jobs_list: Sequence[
RegisteredFunctionJobWithStatus | RegisteredFunctionJob
] = []
if include_status:
function_jobs_list, meta = (
function_jobs_list_ws, meta = (
await function_job_service.list_function_jobs_with_status(
pagination_offset=page_params.offset,
pagination_limit=page_params.limit,
Expand All @@ -153,7 +148,7 @@ async def list_function_jobs(
)
# the code below should ideally be in the service layer, but this can only be done if the
# celery status resolution is done in the service layer too
for function_job_wso in function_jobs_list:
for function_job_wso in function_jobs_list_ws:
if (
function_job_wso.status.status
not in (
Expand Down Expand Up @@ -183,15 +178,21 @@ async def list_function_jobs(
async_pg_engine=async_pg_engine,
)
)
else:
function_jobs_list, meta = await function_job_service.list_function_jobs(
pagination_offset=page_params.offset,
pagination_limit=page_params.limit,
filter_by_function_job_ids=filters.function_job_ids,
filter_by_function_job_collection_id=filters.function_job_collection_id,
filter_by_function_id=filters.function_id,

return create_page(
function_jobs_list_ws,
total=meta.total,
params=page_params,
)

function_jobs_list, meta = await function_job_service.list_function_jobs(
pagination_offset=page_params.offset,
pagination_limit=page_params.limit,
filter_by_function_job_ids=filters.function_job_ids,
filter_by_function_job_collection_id=filters.function_job_collection_id,
filter_by_function_id=filters.function_id,
)

return create_page(
function_jobs_list,
total=meta.total,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
from models_library.functions import FunctionJobID
from models_library.functions import (
FunctionJobID,
RegisteredFunctionJob,
RegisteredFunctionJobWithStatus,
)
from pydantic import BaseModel

from ...models.pagination import Page
from ...models.schemas.jobs import JobInputs


class PreRegisteredFunctionJobData(BaseModel):
function_job_id: FunctionJobID
job_inputs: JobInputs


class PageRegisteredFunctionJobWithorWithoutStatus(
Page[RegisteredFunctionJobWithStatus | RegisteredFunctionJob] # order is important
):
# This class is created specifically to provide a name for this in openapi.json.
# When using an alias the python-client generates too long file name
pass
Loading