Skip to content

Commit ee5c59c

Browse files
author
Andrei Neagu
committed
wip: trying to make ci work
1 parent 3cca5f9 commit ee5c59c

File tree

5 files changed

+29
-25
lines changed

5 files changed

+29
-25
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,10 @@ def validate_template_type(
156156
) -> ProjectTemplateType | None:
157157
type_value = info.data.get("type")
158158
if type_value == ProjectType.STANDARD and v is not None:
159-
msg = "template_type must be None when type is STANDARD"
159+
msg = f"template_type must be {v} when type is {ProjectType.STANDARD}"
160160
raise ValueError(msg)
161161
if type_value == ProjectType.TEMPLATE and v is None:
162-
msg = "template_type must not be None when type is TEMPLATE"
162+
msg = f"template_type must not be {v} when type is {ProjectType.TEMPLATE}"
163163
raise ValueError(msg)
164164
return v
165165

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,18 @@ class BaseProjectModel(BaseModel):
7171
),
7272
]
7373

74+
project_type: Annotated[
75+
ProjectType, Field(alias="type", description="The project type")
76+
]
77+
template_type: Annotated[
78+
ProjectTemplateType | None,
79+
Field(
80+
alias="templateType",
81+
description="The project template type",
82+
examples=["TEMPLATE", "TUTORIAL", "HYPERTOOL"],
83+
),
84+
]
85+
7486
name: Annotated[
7587
str,
7688
Field(description="project name", examples=["Temporal Distortion Simulator"]),
@@ -105,38 +117,26 @@ class BaseProjectModel(BaseModel):
105117
none_to_empty_str_pre_validator
106118
)
107119

120+
@field_validator("project_type", "template_type", mode="before")
121+
@classmethod
122+
def _convert_sql_alchemy_enum(cls, v):
123+
if isinstance(v, Enum):
124+
return v.value
125+
return v
126+
108127

109128
class ProjectAtDB(BaseProjectModel):
110129
# Model used to READ from database
111130

112131
id: Annotated[int, Field(description="The table primary index")]
113132

114-
project_type: Annotated[
115-
ProjectType, Field(alias="type", description="The project type")
116-
]
117-
template_type: Annotated[
118-
ProjectTemplateType | None,
119-
Field(
120-
alias="templateType",
121-
description="The project template type",
122-
examples=["TEMPLATE", "TUTORIAL", "HYPERTOOL"],
123-
),
124-
]
125-
126133
prj_owner: Annotated[int | None, Field(description="The project owner id")]
127134

128135
published: Annotated[
129136
bool | None,
130137
Field(description="Defines if a study is available publicly"),
131138
] = False
132139

133-
@field_validator("project_type", "template_type", mode="before")
134-
@classmethod
135-
def _convert_sql_alchemy_enum(cls, v):
136-
if isinstance(v, Enum):
137-
return v.value
138-
return v
139-
140140
model_config = ConfigDict(
141141
from_attributes=True, use_enum_values=True, populate_by_name=True
142142
)

services/web/server/src/simcore_service_webserver/projects/_projects_repository_legacy_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636

3737
logger = logging.getLogger(__name__)
3838

39-
DB_EXCLUSIVE_COLUMNS = ["type", "id", "published", "hidden"]
39+
DB_EXCLUSIVE_COLUMNS_GET = ["id", "published", "hidden"]
40+
DB_EXCLUSIVE_COLUMNS = [*DB_EXCLUSIVE_COLUMNS_GET, "type"]
4041
SCHEMA_NON_NULL_KEYS = ["thumbnail"]
4142

4243
PermissionStr = Literal["read", "write", "delete"]
@@ -85,7 +86,7 @@ def convert_to_schema_names(
8586
# SEE https://github.com/ITISFoundation/osparc-simcore/issues/3516
8687
converted_args = {}
8788
for col_name, col_value in project_database_data.items():
88-
if col_name in DB_EXCLUSIVE_COLUMNS:
89+
if col_name in DB_EXCLUSIVE_COLUMNS_GET:
8990
continue
9091
converted_value = col_value
9192
if isinstance(col_value, datetime) and col_name not in {"trashed"}:

services/web/server/src/simcore_service_webserver/projects/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ def validate_template_type(
8383
) -> ProjectTemplateType | None:
8484
type_value = info.data.get("type")
8585
if type_value == ProjectType.STANDARD and v is not None:
86-
msg = "template_type must be None when type is STANDARD"
86+
msg = f"template_type must be {v} when type is {ProjectType.STANDARD}"
8787
raise ValueError(msg)
8888
if type_value == ProjectType.TEMPLATE and v is None:
89-
msg = "template_type must not be None when type is TEMPLATE"
89+
msg = f"template_type must not be {v} when type is {ProjectType.TEMPLATE}"
9090
raise ValueError(msg)
9191
return v
9292

services/web/server/tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ async def _setup(
218218
# Pre-defined fields imposed by required properties in schema
219219
project_data: ProjectDict = {}
220220
expected_data: ProjectDict = {
221+
"type": "TEMPLATE" if as_template else "STANDARD",
222+
"templateType": "TEMPLATE" if as_template else None,
221223
"classifiers": [],
222224
"accessRights": {},
223225
"tags": [],
@@ -316,6 +318,7 @@ async def _creator(
316318
parent_project_uuid=parent_project_uuid,
317319
parent_node_id=parent_node_id,
318320
)
321+
print(f"{project_data=}, {expected_data=}")
319322
# Create project here:
320323
resp = await client.post(
321324
f"{url}", json=project_data, headers=headers

0 commit comments

Comments
 (0)