Skip to content

Commit 667b71e

Browse files
committed
removing aiopg
1 parent db5f5cb commit 667b71e

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

services/director-v2/tests/unit/_helpers.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
from collections.abc import Callable
12
from dataclasses import dataclass
2-
from typing import Any, Callable
3+
from typing import Any
34

4-
import aiopg
5-
import aiopg.sa
65
import sqlalchemy as sa
76
from models_library.projects import ProjectAtDB, ProjectID
87
from models_library.projects_nodes_io import NodeID
@@ -31,12 +30,12 @@ class RunningProject(PublishedProject):
3130

3231

3332
async def set_comp_task_outputs(
34-
aiopg_engine: aiopg.sa.engine.Engine,
33+
sqlalchemy_async_engine: AsyncEngine,
3534
node_id: NodeID,
3635
outputs_schema: dict[str, Any],
3736
outputs: dict[str, Any],
3837
) -> None:
39-
async with aiopg_engine.acquire() as conn:
38+
async with sqlalchemy_async_engine.begin() as conn:
4039
await conn.execute(
4140
comp_tasks.update()
4241
.where(comp_tasks.c.node_id == f"{node_id}")
@@ -45,12 +44,12 @@ async def set_comp_task_outputs(
4544

4645

4746
async def set_comp_task_inputs(
48-
aiopg_engine: aiopg.sa.engine.Engine,
47+
sqlalchemy_async_engine: AsyncEngine,
4948
node_id: NodeID,
5049
inputs_schema: dict[str, Any],
5150
inputs: dict[str, Any],
5251
) -> None:
53-
async with aiopg_engine.acquire() as conn:
52+
async with aiopg_engine.begin() as conn:
5453
await conn.execute(
5554
comp_tasks.update()
5655
.where(comp_tasks.c.node_id == f"{node_id}")

services/director-v2/tests/unit/with_dbs/test_utils_dask.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
from typing import Any
1414
from unittest import mock
1515

16-
import aiopg
17-
import aiopg.sa
1816
import pytest
1917
from _helpers import PublishedProject, set_comp_task_inputs, set_comp_task_outputs
2018
from dask_task_models_library.container_tasks.io import (
@@ -244,7 +242,7 @@ def fake_task_output_data(
244242

245243

246244
async def test_parse_output_data(
247-
aiopg_engine: aiopg.sa.engine.Engine,
245+
sqlalchemy_async_engine: AsyncEngine,
248246
published_project: PublishedProject,
249247
user_id: UserID,
250248
fake_io_schema: dict[str, dict[str, str]],
@@ -255,7 +253,7 @@ async def test_parse_output_data(
255253
sleeper_task: CompTaskAtDB = published_project.tasks[1]
256254
no_outputs = {}
257255
await set_comp_task_outputs(
258-
aiopg_engine, sleeper_task.node_id, fake_io_schema, no_outputs
256+
sqlalchemy_async_engine, sleeper_task.node_id, fake_io_schema, no_outputs
259257
)
260258
# mock the set_value function so we can test it is called correctly
261259
mocked_node_ports_set_value_fct = mocker.patch(
@@ -270,7 +268,7 @@ async def test_parse_output_data(
270268
published_project.project.uuid,
271269
sleeper_task.node_id,
272270
)
273-
await parse_output_data(aiopg_engine, dask_job_id, fake_task_output_data)
271+
await parse_output_data(sqlalchemy_async_engine, dask_job_id, fake_task_output_data)
274272

275273
# the FileUrl types are converted to a pure url
276274
expected_values = {
@@ -299,7 +297,6 @@ def _app_config_with_db(
299297

300298
async def test_compute_input_data(
301299
_app_config_with_db: None,
302-
aiopg_engine: aiopg.sa.engine.Engine,
303300
sqlalchemy_async_engine: AsyncEngine,
304301
initialized_app: FastAPI,
305302
user_id: UserID,
@@ -330,7 +327,7 @@ async def test_compute_input_data(
330327
for key, value_type in fake_io_schema.items()
331328
}
332329
await set_comp_task_inputs(
333-
aiopg_engine, sleeper_task.node_id, fake_io_schema, fake_inputs
330+
sqlalchemy_async_engine, sleeper_task.node_id, fake_io_schema, fake_inputs
334331
)
335332

336333
# mock the get_value function so we can test it is called correctly
@@ -378,7 +375,6 @@ def tasks_file_link_scheme(tasks_file_link_type: FileLinkType) -> tuple:
378375

379376
async def test_compute_output_data_schema(
380377
_app_config_with_db: None,
381-
aiopg_engine: aiopg.sa.engine.Engine,
382378
sqlalchemy_async_engine: AsyncEngine,
383379
initialized_app: FastAPI,
384380
user_id: UserID,
@@ -392,7 +388,7 @@ async def test_compute_output_data_schema(
392388
# simulate pre-created file links
393389
no_outputs = {}
394390
await set_comp_task_outputs(
395-
aiopg_engine, sleeper_task.node_id, fake_io_schema, no_outputs
391+
sqlalchemy_async_engine, sleeper_task.node_id, fake_io_schema, no_outputs
396392
)
397393

398394
node_ports = await create_node_ports(
@@ -428,7 +424,7 @@ async def test_compute_output_data_schema(
428424

429425
@pytest.mark.parametrize("entry_exists_returns", [True, False])
430426
async def test_clean_task_output_and_log_files_if_invalid(
431-
aiopg_engine: aiopg.sa.engine.Engine,
427+
sqlalchemy_async_engine: AsyncEngine,
432428
user_id: UserID,
433429
published_project: PublishedProject,
434430
mocked_node_ports_filemanager_fcts: dict[str, mock.MagicMock],
@@ -459,11 +455,11 @@ async def test_clean_task_output_and_log_files_if_invalid(
459455
if value_type["type"] == "data:*/*"
460456
}
461457
await set_comp_task_outputs(
462-
aiopg_engine, sleeper_task.node_id, fake_io_schema, fake_outputs
458+
sqlalchemy_async_engine, sleeper_task.node_id, fake_io_schema, fake_outputs
463459
)
464460
# this should ask for the 2 files + the log file
465461
await clean_task_output_and_log_files_if_invalid(
466-
aiopg_engine,
462+
sqlalchemy_async_engine,
467463
user_id,
468464
published_project.project.uuid,
469465
published_project.tasks[1].node_id,

0 commit comments

Comments
 (0)