Skip to content

Commit 6d362fd

Browse files
committed
cleanup nodeports
1 parent 87820ae commit 6d362fd

File tree

1 file changed

+30
-29
lines changed
  • packages/simcore-sdk/src/simcore_sdk/node_ports_v2

1 file changed

+30
-29
lines changed

packages/simcore-sdk/src/simcore_sdk/node_ports_v2/port.py

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,21 @@ def check_value(cls, v: DataItemValue, info: ValidationInfo) -> DataItemValue:
114114
and not isinstance(v, PortLink)
115115
):
116116
if port_utils.is_file_type(property_type):
117-
if not isinstance(v, (FileLink, DownloadLink)):
118-
raise ValueError(
119-
f"{property_type!r} value does not validate against any of FileLink, DownloadLink or PortLink schemas"
120-
)
117+
if not isinstance(v, FileLink | DownloadLink):
118+
msg = f"{property_type!r} value does not validate against any of FileLink, DownloadLink or PortLink schemas"
119+
raise ValueError(msg)
121120
elif property_type == "ref_contentSchema":
122121
v, _ = validate_port_content(
123122
port_key=info.data.get("key"),
124123
value=v,
125124
unit=None,
126125
content_schema=info.data.get("content_schema", {}),
127126
)
128-
elif isinstance(v, (list, dict)):
129-
raise TypeError(
127+
elif isinstance(v, list | dict):
128+
msg = (
130129
f"Containers as {v} currently only supported within content_schema."
131130
)
131+
raise TypeError(msg)
132132
return v
133133

134134
@field_validator("value_item", "value_concrete", mode="before")
@@ -194,28 +194,29 @@ async def get_value(
194194
)
195195

196196
async def _evaluate() -> ItemValue | None:
197+
# NOTE: review types returned by this function !!!
197198
if isinstance(self.value, PortLink):
198199
# this is a link to another node's port
199-
other_port_itemvalue: None | (
200-
ItemValue
201-
) = await port_utils.get_value_link_from_port_link(
202-
self.value,
203-
# pylint: disable=protected-access
204-
self._node_ports._node_ports_creator_cb,
205-
file_link_type=file_link_type,
200+
other_port_itemvalue: ItemValue | None = (
201+
await port_utils.get_value_link_from_port_link(
202+
self.value,
203+
# pylint: disable=protected-access
204+
self._node_ports._node_ports_creator_cb,
205+
file_link_type=file_link_type,
206+
)
206207
)
207208

208209
return other_port_itemvalue
209210

210211
if isinstance(self.value, FileLink):
211212
# let's get the download/upload link from storage
212-
url_itemvalue: None | (
213-
AnyUrl
214-
) = await port_utils.get_download_link_from_storage(
215-
# pylint: disable=protected-access
216-
user_id=self._node_ports.user_id,
217-
value=self.value,
218-
link_type=file_link_type,
213+
url_itemvalue: AnyUrl | None = (
214+
await port_utils.get_download_link_from_storage(
215+
# pylint: disable=protected-access
216+
user_id=self._node_ports.user_id,
217+
value=self.value,
218+
link_type=file_link_type,
219+
)
219220
)
220221
return url_itemvalue
221222

@@ -256,15 +257,15 @@ async def _evaluate() -> ItemConcreteValue | None:
256257

257258
if isinstance(self.value, PortLink):
258259
# this is a link to another node
259-
other_port_concretevalue: None | (
260-
ItemConcreteValue
261-
) = await port_utils.get_value_from_link(
262-
# pylint: disable=protected-access
263-
key=self.key,
264-
value=self.value,
265-
file_to_key_map=self.file_to_key_map,
266-
node_port_creator=self._node_ports._node_ports_creator_cb, # noqa: SLF001
267-
progress_bar=progress_bar,
260+
other_port_concretevalue: None | ItemConcreteValue = (
261+
await port_utils.get_value_from_link(
262+
# pylint: disable=protected-access
263+
key=self.key,
264+
value=self.value,
265+
file_to_key_map=self.file_to_key_map,
266+
node_port_creator=self._node_ports._node_ports_creator_cb, # noqa: SLF001
267+
progress_bar=progress_bar,
268+
)
268269
)
269270
value = other_port_concretevalue
270271

0 commit comments

Comments
 (0)