Skip to content

Commit 663de5f

Browse files
authored
Merge branch 'master' into enh/support-center-feedback
2 parents 82079c8 + 7e42fd0 commit 663de5f

File tree

12 files changed

+164
-102
lines changed

12 files changed

+164
-102
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

services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_tasks/_utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ async def generate_tasks_list_from_project(
400400
raise WalletNotEnoughCreditsError(
401401
wallet_name=wallet_info.wallet_name,
402402
wallet_credit_amount=wallet_info.wallet_credit_amount,
403+
user_id=user_id,
404+
product_name=product_name,
405+
project_id=project.uuid,
403406
)
404407

405408
assert rabbitmq_rpc_client # nosec

services/director-v2/src/simcore_service_director_v2/modules/db/tables.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@
1010
)
1111
from simcore_postgres_database.models.projects import ProjectType, projects
1212
from simcore_postgres_database.models.projects_networks import projects_networks
13+
from simcore_postgres_database.models.projects_nodes import projects_nodes
1314

14-
__all__ = [
15+
__all__: tuple[str, ...] = (
16+
"NodeClass",
17+
"ProjectType",
18+
"StateType",
1519
"comp_pipeline",
20+
"comp_run_snapshot_tasks",
1621
"comp_runs",
1722
"comp_tasks",
1823
"groups_extra_properties",
19-
"NodeClass",
20-
"projects_networks",
2124
"projects",
22-
"ProjectType",
23-
"StateType",
25+
"projects_networks",
26+
"projects_nodes",
2427
"user_to_groups",
25-
"comp_run_snapshot_tasks",
26-
]
28+
)
29+
30+
# nopycln: file

services/director-v2/src/simcore_service_director_v2/utils/dags.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def create_complete_dag(workbench: NodesDict) -> nx.DiGraph:
2929
dag_graph: nx.DiGraph = nx.DiGraph()
3030
for node_id, node in workbench.items():
3131
assert node.state # nosec
32+
3233
dag_graph.add_node(
3334
node_id,
3435
name=node.label,
@@ -43,6 +44,9 @@ def create_complete_dag(workbench: NodesDict) -> nx.DiGraph:
4344
if node.input_nodes:
4445
for input_node_id in node.input_nodes:
4546
predecessor_node = workbench.get(f"{input_node_id}")
47+
assert ( # nosec
48+
predecessor_node
49+
), f"Node {input_node_id} not found in workbench"
4650
if predecessor_node:
4751
dag_graph.add_edge(str(input_node_id), node_id)
4852

services/web/server/tests/data/fake-project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"x": 1073,
7878
"y": 307
7979
},
80-
"progress": 100,
80+
"progress": 100.0,
8181
"state": {
8282
"currentStatus": "NOT_STARTED",
8383
"lock_state": {

services/web/server/tests/unit/with_dbs/02/test_projects_crud_handlers.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sqlalchemy as sa
1616
from aiohttp.test_utils import TestClient
1717
from aioresponses import aioresponses
18+
from deepdiff import DeepDiff
1819
from faker import Faker
1920
from models_library.api_schemas_directorv2.dynamic_services import (
2021
GetProjectInactivityResponse,
@@ -23,7 +24,10 @@
2324
from models_library.products import ProductName
2425
from pydantic import TypeAdapter
2526
from pytest_mock import MockerFixture
26-
from pytest_simcore.helpers.assert_checks import assert_status
27+
from pytest_simcore.helpers.assert_checks import (
28+
assert_equal_ignoring_none,
29+
assert_status,
30+
)
2731
from pytest_simcore.helpers.webserver_parametrizations import (
2832
ExpectedResponse,
2933
MockedStorageSubsystem,
@@ -174,7 +178,9 @@ async def _assert_get_same_project(
174178
project_permalink = data.pop("permalink", None)
175179
folder_id = data.pop("folderId", None)
176180

177-
assert data == {k: project[k] for k in data}
181+
assert not DeepDiff(
182+
data, {k: project[k] for k in data}, exclude_paths="root['lastChangeDate']"
183+
)
178184

179185
if project_state:
180186
assert ProjectStateOutputSchema.model_validate(project_state)
@@ -215,7 +221,11 @@ async def test_list_projects(
215221
project_permalink = got.pop("permalink")
216222
folder_id = got.pop("folderId")
217223

218-
assert got == {k: template_project[k] for k in got}
224+
assert not DeepDiff(
225+
got,
226+
{k: template_project[k] for k in got},
227+
exclude_paths="root['lastChangeDate']",
228+
)
219229

220230
assert not ProjectStateOutputSchema(
221231
**project_state
@@ -228,7 +238,11 @@ async def test_list_projects(
228238
project_permalink = got.pop("permalink", None)
229239
folder_id = got.pop("folderId")
230240

231-
assert got == {k: user_project[k] for k in got}
241+
assert not DeepDiff(
242+
got,
243+
{k: user_project[k] for k in got},
244+
exclude_paths="root['lastChangeDate']",
245+
)
232246

233247
assert ProjectStateOutputSchema(**project_state)
234248
assert project_permalink is None
@@ -245,7 +259,12 @@ async def test_list_projects(
245259
project_permalink = got.pop("permalink", None)
246260
folder_id = got.pop("folderId")
247261

248-
assert got == {k: user_project[k] for k in got}
262+
assert not DeepDiff(
263+
got,
264+
{k: user_project[k] for k in got},
265+
exclude_paths="root['lastChangeDate']",
266+
)
267+
249268
assert not ProjectStateOutputSchema(
250269
**project_state
251270
).share_state.locked, "Single user does not lock"
@@ -263,7 +282,11 @@ async def test_list_projects(
263282
project_permalink = got.pop("permalink")
264283
folder_id = got.pop("folderId")
265284

266-
assert got == {k: template_project[k] for k in got}
285+
assert not DeepDiff(
286+
got,
287+
{k: template_project[k] for k in got},
288+
exclude_paths="root['lastChangeDate']",
289+
)
267290
assert not ProjectStateOutputSchema(
268291
**project_state
269292
).share_state.locked, "Templates are not locked"
@@ -632,7 +655,7 @@ async def test_new_template_from_project(
632655
)
633656

634657
assert len(templates) == 1
635-
assert templates[0] == template_project
658+
assert_equal_ignoring_none(template_project, templates[0])
636659

637660
assert template_project["name"] == user_project["name"]
638661
assert template_project["description"] == user_project["description"]

services/web/server/tests/unit/with_dbs/02/test_projects_nodes_handlers__patch.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import pytest
1414
from aiohttp.test_utils import TestClient
15+
from deepdiff import DeepDiff
1516
from pytest_mock.plugin import MockerFixture
1617
from pytest_simcore.helpers.assert_checks import assert_status
1718
from pytest_simcore.helpers.webserver_users import UserInfoDict
@@ -168,7 +169,9 @@ async def test_patch_project_node(
168169
"output_1": {
169170
"store": 0,
170171
"path": "9934cba6-4b51-11ef-968a-02420a00f1c1/571ffc8d-fa6e-411f-afc8-9c62d08dd2fa/matus.txt",
172+
"label": "matus.txt",
171173
"eTag": "d41d8cd98f00b204e9800998ecf8427e",
174+
"dataset": None,
172175
}
173176
}
174177
}
@@ -185,7 +188,6 @@ async def test_patch_project_node(
185188
_tested_node = data["workbench"][node_id]
186189

187190
assert _tested_node["label"] == "testing-string"
188-
assert _tested_node["progress"] is None
189191
assert _tested_node["key"] == _patch_key["key"]
190192
assert _tested_node["version"] == _patch_version["version"]
191193
assert _tested_node["inputs"] == _patch_inputs["inputs"]
@@ -262,10 +264,14 @@ async def test_patch_project_node_inputs_notifies(
262264
await assert_status(resp, expected)
263265
assert mocked_notify_project_node_update.call_count > 1
264266
# 1 message per node updated
265-
assert [
266-
call_args[0][2]
267-
for call_args in mocked_notify_project_node_update.await_args_list
268-
] == list(user_project["workbench"].keys())
267+
assert not DeepDiff(
268+
[
269+
call_args[0][2]
270+
for call_args in mocked_notify_project_node_update.await_args_list
271+
],
272+
list(user_project["workbench"].keys()),
273+
ignore_order=True,
274+
)
269275

270276

271277
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)