Skip to content

Commit f754e78

Browse files
continue fixing
1 parent e72c7f6 commit f754e78

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

services/web/server/src/simcore_service_webserver/catalog/_api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,17 @@ async def get_compatible_inputs_given_source_output(
284284
from_service_key, from_service_version, from_output_key, ctx
285285
)
286286

287-
from_output: ServiceOutput = ServiceOutput.construct(
288-
**service_output.dict(include=ServiceOutput.__fields__.keys())
287+
from_output: ServiceOutput = ServiceOutput.model_construct(
288+
**service_output.model_dump(include=ServiceOutput.model_fields.keys())
289289
)
290290

291291
# N inputs
292292
service_inputs = await list_service_inputs(service_key, service_version, ctx)
293293

294294
def iter_service_inputs() -> Iterator[tuple[ServiceInputKey, ServiceInput]]:
295295
for service_input in service_inputs:
296-
yield service_input.key_id, ServiceInput.construct(
297-
**service_input.dict(include=ServiceInput.__fields__.keys())
296+
yield service_input.key_id, ServiceInput.model_construct(
297+
**service_input.model_dump(include=ServiceInput.model_fields.keys())
298298
)
299299

300300
# check
@@ -352,16 +352,16 @@ async def get_compatible_outputs_given_target_input(
352352

353353
def iter_service_outputs() -> Iterator[tuple[ServiceOutputKey, ServiceOutput]]:
354354
for service_output in service_outputs:
355-
yield service_output.key_id, ServiceOutput.construct(
356-
**service_output.dict(include=ServiceOutput.__fields__.keys())
355+
yield service_output.key_id, ServiceOutput.model_construct(
356+
**service_output.model_dump(include=ServiceOutput.model_fields.keys())
357357
)
358358

359359
# 1 input
360360
service_input = await get_service_input(
361361
to_service_key, to_service_version, to_input_key, ctx
362362
)
363-
to_input: ServiceInput = ServiceInput.construct(
364-
**service_input.dict(include=ServiceInput.__fields__.keys())
363+
to_input: ServiceInput = ServiceInput.model_construct(
364+
**service_input.model_dump(include=ServiceInput.model_fields.keys())
365365
)
366366

367367
# check

services/web/server/src/simcore_service_webserver/products/_model.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
import re
33
import string
4-
from typing import Any
4+
from typing import Annotated, Any
55

66
from models_library.basic_regex import (
77
PUBLIC_VARIABLE_NAME_RE,
@@ -11,7 +11,14 @@
1111
from models_library.emails import LowerCaseEmailStr
1212
from models_library.products import ProductName
1313
from models_library.utils.change_case import snake_to_camel
14-
from pydantic import BaseModel, ConfigDict, Field, PositiveInt, field_validator
14+
from pydantic import (
15+
BaseModel,
16+
BeforeValidator,
17+
ConfigDict,
18+
Field,
19+
PositiveInt,
20+
field_validator,
21+
)
1522
from simcore_postgres_database.models.products import (
1623
EmailFeedback,
1724
Forum,
@@ -48,7 +55,9 @@ class Product(BaseModel):
4855
description="Short display name for SMS",
4956
)
5057

51-
host_regex: re.Pattern = Field(..., description="Host regex")
58+
host_regex: Annotated[re.Pattern, BeforeValidator(str.strip)] = Field(
59+
..., description="Host regex"
60+
)
5261

5362
support_email: LowerCaseEmailStr = Field(
5463
...,
@@ -121,23 +130,14 @@ def _validate_name(cls, v):
121130
raise ValueError(msg)
122131
return v
123132

124-
@validator("host_regex", pre=True)
125-
@classmethod
126-
def _strip_whitespaces(cls, v):
127-
if v and isinstance(v, str):
128-
# Prevents unintended leading & trailing spaces when added
129-
# manually in the database
130-
return v.strip()
131-
return v
132-
133133
@property
134134
def twilio_alpha_numeric_sender_id(self) -> str:
135135
return self.short_name or self.display_name.replace(string.punctuation, "")[:11]
136136

137137
model_config = ConfigDict(
138138
alias_generator=snake_to_camel,
139139
populate_by_name=True,
140-
str_strip_whitespace = True,
140+
str_strip_whitespace=True,
141141
frozen=True,
142142
from_attributes=True,
143143
extra="ignore",

services/web/server/src/simcore_service_webserver/studies_dispatcher/_projects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _create_project_with_filepicker_and_service(
147147
viewer_info: ViewerInfo,
148148
) -> Project:
149149
file_picker, file_picker_output_id = _create_file_picker(
150-
download_link, output_label=None
150+
f"{download_link}", output_label=None
151151
)
152152

153153
viewer_service = Node(
@@ -346,7 +346,7 @@ async def get_or_create_project_with_file(
346346
):
347347
# nodes
348348
file_picker, _ = _create_file_picker(
349-
file_params.download_link, output_label=file_params.file_name
349+
f"{file_params.download_link}", output_label=file_params.file_name
350350
)
351351

352352
# project

0 commit comments

Comments
 (0)