Skip to content

Commit 731bc9e

Browse files
fix missue with 422
1 parent a85096b commit 731bc9e

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

packages/models-library/src/models_library/api_schemas_directorv2/computations.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ class ComputationCreate(BaseModel):
7373
description="contains information about the wallet used to bill the running service"
7474
),
7575
] = None
76-
collection_run_id: CollectionRunID
76+
collection_run_id: Annotated[
77+
CollectionRunID | None,
78+
Field(
79+
description="contains information about the wallet used to bill the running service"
80+
),
81+
] = None
7782

7883
@field_validator("product_name")
7984
@classmethod
@@ -85,6 +90,20 @@ def _ensure_product_name_defined_if_computation_starts(
8590
raise ValueError(msg)
8691
return v
8792

93+
@field_validator("collection_run_id")
94+
@classmethod
95+
def _ensure_collection_run_id_dependency_on_start_pipeline(
96+
cls, v, info: ValidationInfo
97+
):
98+
start_pipeline = info.data.get("start_pipeline")
99+
if start_pipeline and v is None:
100+
msg = "collection_run_id must be provided when start_pipeline is True!"
101+
raise ValueError(msg)
102+
if not start_pipeline and v is not None:
103+
msg = "collection_run_id must be None when start_pipeline is False!"
104+
raise ValueError(msg)
105+
return v
106+
88107

89108
class ComputationStop(BaseModel):
90109
user_id: UserID

services/director-v2/openapi.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,18 +1350,25 @@
13501350
"description": "contains information about the wallet used to bill the running service"
13511351
},
13521352
"collection_run_id": {
1353-
"type": "string",
1354-
"format": "uuid",
1355-
"title": "Collection Run Id"
1353+
"anyOf": [
1354+
{
1355+
"type": "string",
1356+
"format": "uuid"
1357+
},
1358+
{
1359+
"type": "null"
1360+
}
1361+
],
1362+
"title": "Collection Run Id",
1363+
"description": "contains information about the wallet used to bill the running service"
13561364
}
13571365
},
13581366
"type": "object",
13591367
"required": [
13601368
"user_id",
13611369
"project_id",
13621370
"product_name",
1363-
"product_api_base_url",
1364-
"collection_run_id"
1371+
"product_api_base_url"
13651372
],
13661373
"title": "ComputationCreate"
13671374
},

0 commit comments

Comments
 (0)