Skip to content

Commit d9881a1

Browse files
fix: validate ignoring workbench
1 parent f5ae1c5 commit d9881a1

File tree

2 files changed

+15
-5
lines changed
  • packages/models-library/src/models_library
  • services/storage/src/simcore_service_storage/modules/db

2 files changed

+15
-5
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,20 @@ class BaseProjectModel(BaseModel):
108108

109109
# Pipeline of nodes (SEE projects_nodes.py)
110110
# FIXME: pedro checks this one
111-
# NOTE: GCG: a validation failed (See: services/storage/src/simcore_service_storage/modules/db/projects.py)
112-
workbench: Annotated[
113-
NodesDict, Field(description="Project's pipeline", exclude=True)
114-
]
111+
# NOTE: GCR: a validation failed (See: services/storage/src/simcore_service_storage/modules/db/projects.py)
112+
workbench: Annotated[NodesDict, Field(description="Project's pipeline")]
113+
114+
@classmethod
115+
def model_validate_ignoring_workbench(cls, obj: Any):
116+
if isinstance(obj, dict):
117+
data = dict(obj)
118+
data.pop("workbench", None)
119+
else:
120+
data = obj
121+
model = cls.model_validate(data)
122+
if isinstance(obj, dict) and "workbench" in obj:
123+
model.workbench = obj["workbench"]
124+
return model
115125

116126

117127
class ProjectAtDB(BaseProjectModel):

services/storage/src/simcore_service_storage/modules/db/projects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def list_valid_projects_in(
3131
)
3232
):
3333
with suppress(ValidationError):
34-
yield ProjectAtDB.model_validate(row)
34+
yield ProjectAtDB.model_validate_ignoring_workbench(row._asdict())
3535

3636
async def get_project_id_and_node_id_to_names_map(
3737
self,

0 commit comments

Comments
 (0)