Skip to content

Commit f02fe84

Browse files
improve
1 parent c79dc06 commit f02fe84

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

packages/postgres-database/src/simcore_postgres_database/utils_comp_runs.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from typing import cast
23

34
import sqlalchemy as sa
@@ -7,13 +8,15 @@
78
from .models.comp_runs import comp_runs
89
from .utils_repos import pass_or_acquire_connection
910

11+
_logger = logging.getLogger(__name__)
12+
1013

1114
async def get_latest_run_id_for_project(
1215
engine: AsyncEngine,
1316
conn: AsyncConnection | None = None,
1417
*,
1518
project_id: str,
16-
) -> PositiveInt:
19+
) -> PositiveInt | None:
1720
# Get latest run per (project_uuid, user_id)
1821
project_and_user_latest_runs = (
1922
sa.select(
@@ -68,6 +71,7 @@ async def get_latest_run_id_for_project(
6871
result = await _conn.execute(base_select_query)
6972
row = result.one_or_none()
7073
if not row:
71-
msg = f"get_latest_run_id_for_project did not return any row for project_id={project_id}"
72-
raise ValueError(msg)
74+
msg = f"get_latest_run_id_for_project did not return any row for project_id={project_id} (MD: I think this should not happen, but if it happens contact MD/SAN)"
75+
_logger.error(msg)
76+
return None
7377
return cast(PositiveInt, row.run_id)

packages/simcore-sdk/src/simcore_sdk/node_ports_common/dbmanager.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,19 @@ async def _update_comp_run_snapshot_tasks_if_computational(
6666
_latest_run_id = await get_latest_run_id_for_project(
6767
engine, connection, project_id=project_id
6868
)
69-
await update_for_run_id_and_node_id(
70-
engine,
71-
connection,
72-
run_id=_latest_run_id,
73-
node_id=node_uuid,
74-
data={
75-
"schema": node_configuration["schema"],
76-
"inputs": node_configuration["inputs"],
77-
"outputs": node_configuration["outputs"],
78-
"run_hash": node_configuration.get("run_hash"),
79-
},
80-
)
69+
if _latest_run_id is not None:
70+
await update_for_run_id_and_node_id(
71+
engine,
72+
connection,
73+
run_id=_latest_run_id,
74+
node_id=node_uuid,
75+
data={
76+
"schema": node_configuration["schema"],
77+
"inputs": node_configuration["inputs"],
78+
"outputs": node_configuration["outputs"],
79+
"run_hash": node_configuration.get("run_hash"),
80+
},
81+
)
8182

8283

8384
class DBContextManager:

0 commit comments

Comments
 (0)