diff --git a/packages/service-library/src/servicelib/fastapi/long_running_tasks/_client.py b/packages/service-library/src/servicelib/fastapi/long_running_tasks/_client.py index a00c2417e49c..4593bbf7b01d 100644 --- a/packages/service-library/src/servicelib/fastapi/long_running_tasks/_client.py +++ b/packages/service-library/src/servicelib/fastapi/long_running_tasks/_client.py @@ -2,7 +2,8 @@ import functools import logging import warnings -from typing import Any, Awaitable, Callable, Final +from collections.abc import Awaitable, Callable +from typing import Any, Final from fastapi import FastAPI, status from httpx import AsyncClient, HTTPError @@ -13,13 +14,8 @@ from tenacity.stop import stop_after_attempt from tenacity.wait import wait_exponential -from ...long_running_tasks._errors import GenericClientError, TaskClientResultError -from ...long_running_tasks._models import ( - ClientConfiguration, - TaskId, - TaskResult, - TaskStatus, -) +from ...long_running_tasks._errors import GenericClientError +from ...long_running_tasks._models import ClientConfiguration, TaskId, TaskStatus DEFAULT_HTTP_REQUESTS_TIMEOUT: Final[PositiveFloat] = 15 @@ -85,7 +81,7 @@ def log_it(retry_state: RetryCallState) -> None: def retry_on_http_errors( - request_func: Callable[..., Awaitable[Any]] + request_func: Callable[..., Awaitable[Any]], ) -> Callable[..., Awaitable[Any]]: """ Will retry the request on `httpx.HTTPError`. @@ -173,10 +169,7 @@ async def get_task_result( body=result.text, ) - task_result = TaskResult.model_validate(result.json()) - if task_result.error is not None: - raise TaskClientResultError(message=task_result.error) - return task_result.result + return result.json() @retry_on_http_errors async def cancel_and_delete_task( diff --git a/packages/service-library/src/servicelib/fastapi/long_running_tasks/_context_manager.py b/packages/service-library/src/servicelib/fastapi/long_running_tasks/_context_manager.py index 1b0f47449b3c..c16fadd8be2b 100644 --- a/packages/service-library/src/servicelib/fastapi/long_running_tasks/_context_manager.py +++ b/packages/service-library/src/servicelib/fastapi/long_running_tasks/_context_manager.py @@ -1,7 +1,8 @@ import asyncio from asyncio.log import logger +from collections.abc import AsyncIterator from contextlib import asynccontextmanager -from typing import Any, AsyncIterator, Final +from typing import Any, Final from pydantic import PositiveFloat @@ -87,8 +88,7 @@ async def periodic_task_result( - `status_poll_interval` optional: when waiting for a task to finish, how frequent should the server be queried - raises: `TaskClientResultError` if the task finished with an error instead of - the expected result + raises: the original expcetion the task raised, if any raises: `asyncio.TimeoutError` NOTE: the remote task will also be removed """ diff --git a/packages/service-library/src/servicelib/fastapi/long_running_tasks/_routes.py b/packages/service-library/src/servicelib/fastapi/long_running_tasks/_routes.py index 260a9e9d0b3e..b56ba3d21ddd 100644 --- a/packages/service-library/src/servicelib/fastapi/long_running_tasks/_routes.py +++ b/packages/service-library/src/servicelib/fastapi/long_running_tasks/_routes.py @@ -1,6 +1,6 @@ from typing import Annotated, Any -from fastapi import APIRouter, Depends, Query, Request, status +from fastapi import APIRouter, Depends, Request, status from ...long_running_tasks._errors import TaskNotCompletedError, TaskNotFoundError from ...long_running_tasks._models import TaskGet, TaskId, TaskResult, TaskStatus @@ -60,16 +60,10 @@ async def get_task_result( request: Request, task_id: TaskId, tasks_manager: Annotated[TasksManager, Depends(get_tasks_manager)], - *, - return_exception: Annotated[bool, Query()] = False, ) -> TaskResult | Any: assert request # nosec - # TODO: refactor this to use same as in https://github.com/ITISFoundation/osparc-simcore/issues/3265 try: - if return_exception: - task_result = tasks_manager.get_task_result(task_id, with_task_context=None) - else: - task_result = tasks_manager.get_task_result_old(task_id=task_id) + task_result = tasks_manager.get_task_result(task_id, with_task_context=None) await tasks_manager.remove_task( task_id, with_task_context=None, reraise_errors=False ) diff --git a/packages/service-library/src/servicelib/fastapi/long_running_tasks/client.py b/packages/service-library/src/servicelib/fastapi/long_running_tasks/client.py index c82bde0fe4e7..62b72256000c 100644 --- a/packages/service-library/src/servicelib/fastapi/long_running_tasks/client.py +++ b/packages/service-library/src/servicelib/fastapi/long_running_tasks/client.py @@ -10,7 +10,11 @@ import httpx from fastapi import status from models_library.api_schemas_long_running_tasks.base import TaskProgress -from models_library.api_schemas_long_running_tasks.tasks import TaskGet, TaskStatus +from models_library.api_schemas_long_running_tasks.tasks import ( + TaskGet, + TaskResult, + TaskStatus, +) from tenacity import ( AsyncRetrying, TryAgain, @@ -23,7 +27,6 @@ from yarl import URL from ...long_running_tasks._constants import DEFAULT_POLL_INTERVAL_S, HOUR -from ...long_running_tasks._errors import TaskClientResultError from ...long_running_tasks._models import ( ClientConfiguration, LRTask, @@ -32,7 +35,7 @@ ProgressPercent, RequestBody, ) -from ...long_running_tasks._task import TaskId, TaskResult +from ...long_running_tasks._task import TaskId from ...rest_responses import unwrap_envelope_if_required from ._client import DEFAULT_HTTP_REQUESTS_TIMEOUT, Client, setup from ._context_manager import periodic_task_result @@ -97,7 +100,7 @@ async def _wait_for_completion( @retry(**_DEFAULT_FASTAPI_RETRY_POLICY) async def _task_result(session: httpx.AsyncClient, result_url: URL) -> Any: - response = await session.get(f"{result_url}", params={"return_exception": True}) + response = await session.get(f"{result_url}") response.raise_for_status() if response.status_code != status.HTTP_204_NO_CONTENT: return unwrap_envelope_if_required(response.json()) @@ -155,7 +158,6 @@ async def long_running_task_request( "ProgressCallback", "ProgressMessage", "ProgressPercent", - "TaskClientResultError", "TaskId", "TaskResult", "periodic_task_result", diff --git a/packages/service-library/src/servicelib/fastapi/long_running_tasks/server.py b/packages/service-library/src/servicelib/fastapi/long_running_tasks/server.py index 1711b5449bd4..b9a29d1d90a4 100644 --- a/packages/service-library/src/servicelib/fastapi/long_running_tasks/server.py +++ b/packages/service-library/src/servicelib/fastapi/long_running_tasks/server.py @@ -6,11 +6,12 @@ running task. The client will take care of recovering the result from it. """ +from models_library.api_schemas_long_running_tasks.tasks import TaskResult + from ...long_running_tasks._errors import TaskAlreadyRunningError, TaskCancelledError from ...long_running_tasks._task import ( TaskId, TaskProgress, - TaskResult, TasksManager, TaskStatus, start_task, diff --git a/packages/service-library/src/servicelib/long_running_tasks/_errors.py b/packages/service-library/src/servicelib/long_running_tasks/_errors.py index 44dc03157f20..33439c6436f3 100644 --- a/packages/service-library/src/servicelib/long_running_tasks/_errors.py +++ b/packages/service-library/src/servicelib/long_running_tasks/_errors.py @@ -4,50 +4,36 @@ class BaseLongRunningError(OsparcErrorMixin, Exception): """base exception for this module""" - code: str = "long_running_task.base_long_running_error" # type: ignore[assignment] - class TaskAlreadyRunningError(BaseLongRunningError): - code: str = "long_running_task.task_already_running" msg_template: str = "{task_name} must be unique, found: '{managed_task}'" class TaskNotFoundError(BaseLongRunningError): - code: str = "long_running_task.task_not_found" msg_template: str = "No task with {task_id} found" class TaskNotCompletedError(BaseLongRunningError): - code: str = "long_running_task.task_not_completed" msg_template: str = "Task {task_id} has not finished yet" class TaskCancelledError(BaseLongRunningError): - code: str = "long_running_task.task_cancelled_error" msg_template: str = "Task {task_id} was cancelled before completing" class TaskExceptionError(BaseLongRunningError): - code: str = "long_running_task.task_exception_error" msg_template: str = ( "Task {task_id} finished with exception: '{exception}'\n{traceback}" ) class TaskClientTimeoutError(BaseLongRunningError): - code: str = "long_running_task.client.timed_out_waiting_for_response" msg_template: str = ( "Timed out after {timeout} seconds while awaiting '{task_id}' to complete" ) class GenericClientError(BaseLongRunningError): - code: str = "long_running_task.client.generic_error" msg_template: str = ( "Unexpected error while '{action}' for '{task_id}': status={status} body={body}" ) - - -class TaskClientResultError(BaseLongRunningError): - code: str = "long_running_task.client.task_raised_error" - msg_template: str = "{message}" diff --git a/packages/service-library/src/servicelib/long_running_tasks/_task.py b/packages/service-library/src/servicelib/long_running_tasks/_task.py index 641e78a96a86..b1b0bedfcc05 100644 --- a/packages/service-library/src/servicelib/long_running_tasks/_task.py +++ b/packages/service-library/src/servicelib/long_running_tasks/_task.py @@ -22,7 +22,7 @@ TaskNotCompletedError, TaskNotFoundError, ) -from ._models import TaskId, TaskName, TaskResult, TaskStatus, TrackedTask +from ._models import TaskId, TaskName, TaskStatus, TrackedTask logger = logging.getLogger(__name__) @@ -241,36 +241,6 @@ def get_task_result( # the task was cancelled raise TaskCancelledError(task_id=task_id) from exc - def get_task_result_old(self, task_id: TaskId) -> TaskResult: - """ - returns: the result of the task - - raises TaskNotFoundError if the task cannot be found - """ - tracked_task = self._get_tracked_task(task_id, {}) - - if not tracked_task.task.done(): - raise TaskNotCompletedError(task_id=task_id) - - error: TaskExceptionError | TaskCancelledError - try: - exception = tracked_task.task.exception() - if exception is not None: - formatted_traceback = "\n".join( - traceback.format_tb(exception.__traceback__) - ) - error = TaskExceptionError( - task_id=task_id, exception=exception, traceback=formatted_traceback - ) - logger.warning("Task %s finished with error: %s", task_id, f"{error}") - return TaskResult(result=None, error=f"{error}") - except asyncio.CancelledError: - error = TaskCancelledError(task_id=task_id) - logger.warning("Task %s was cancelled", task_id) - return TaskResult(result=None, error=f"{error}") - - return TaskResult(result=tracked_task.task.result(), error=None) - async def cancel_task( self, task_id: TaskId, with_task_context: TaskContext | None ) -> None: @@ -354,12 +324,12 @@ async def close(self) -> None: class TaskProtocol(Protocol): - async def __call__(self, progress: TaskProgress, *args: Any, **kwargs: Any) -> Any: - ... + async def __call__( + self, progress: TaskProgress, *args: Any, **kwargs: Any + ) -> Any: ... @property - def __name__(self) -> str: - ... + def __name__(self) -> str: ... def start_task( @@ -449,7 +419,5 @@ async def _progress_task(progress: TaskProgress, handler: TaskProtocol): "TaskProgress", "TaskProtocol", "TaskStatus", - "TaskResult", "TrackedTask", - "TaskResult", ) diff --git a/packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks.py b/packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks.py index 52527f138d98..84146c6b0dc6 100644 --- a/packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks.py +++ b/packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks.py @@ -103,9 +103,9 @@ async def _caller(app: FastAPI, client: AsyncClient, **query_kwargs) -> TaskId: @pytest.fixture -def wait_for_task() -> Callable[ - [FastAPI, AsyncClient, TaskId, TaskContext], Awaitable[None] -]: +def wait_for_task() -> ( + Callable[[FastAPI, AsyncClient, TaskId, TaskContext], Awaitable[None]] +): async def _waiter( app: FastAPI, client: AsyncClient, @@ -183,9 +183,7 @@ async def test_workflow( result = await client.get(f"{result_url}") # NOTE: this is DIFFERENT than with aiohttp where we return the real result assert result.status_code == status.HTTP_200_OK - task_result = long_running_tasks.server.TaskResult.model_validate(result.json()) - assert not task_result.error - assert task_result.result == [f"{x}" for x in range(10)] + assert result.json() == [f"{x}" for x in range(10)] # getting the result again should raise a 404 result = await client.get(result_url) assert result.status_code == status.HTTP_404_NOT_FOUND @@ -220,19 +218,9 @@ async def test_failing_task_returns_error( await wait_for_task(app, client, task_id, {}) # get the result result_url = app.url_path_for("get_task_result", task_id=task_id) - result = await client.get(f"{result_url}") - assert result.status_code == status.HTTP_200_OK - task_result = long_running_tasks.server.TaskResult.model_validate(result.json()) - - assert not task_result.result - assert task_result.error - assert task_result.error.startswith(f"Task {task_id} finished with exception: ") - assert 'raise RuntimeError("We were asked to fail!!")' in task_result.error - # NOTE: this is not yet happening with fastapi version of long running task - # assert "errors" in task_result.error - # assert len(task_result.error["errors"]) == 1 - # assert task_result.error["errors"][0]["code"] == "RuntimeError" - # assert task_result.error["errors"][0]["message"] == "We were asked to fail!!" + with pytest.raises(RuntimeError) as exec_info: + await client.get(f"{result_url}") + assert f"{exec_info.value}" == "We were asked to fail!!" async def test_get_results_before_tasks_finishes_returns_404( diff --git a/packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks_context_manager.py b/packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks_context_manager.py index 985cfca2de63..b0db697a6ad9 100644 --- a/packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks_context_manager.py +++ b/packages/service-library/tests/fastapi/long_running_tasks/test_long_running_tasks_context_manager.py @@ -2,7 +2,8 @@ # pylint: disable=unused-argument import asyncio -from typing import AsyncIterable, Final +from collections.abc import AsyncIterable +from typing import Final import pytest from asgi_lifespan import LifespanManager @@ -24,9 +25,10 @@ get_tasks_manager, ) from servicelib.fastapi.long_running_tasks.server import setup as setup_server -from servicelib.fastapi.long_running_tasks.server import start_task +from servicelib.fastapi.long_running_tasks.server import ( + start_task, +) from servicelib.long_running_tasks._errors import ( - TaskClientResultError, TaskClientTimeoutError, ) @@ -149,7 +151,7 @@ async def test_task_result_task_result_is_an_error( url = TypeAdapter(AnyHttpUrl).validate_python("http://backgroud.testserver.io/") client = Client(app=bg_task_app, async_client=async_client, base_url=url) - with pytest.raises(TaskClientResultError) as exec_info: + with pytest.raises(RuntimeError, match="I am failing as requested"): async with periodic_task_result( client, task_id, @@ -157,8 +159,6 @@ async def test_task_result_task_result_is_an_error( status_poll_interval=TASK_SLEEP_INTERVAL / 3, ): pass - assert f"{exec_info.value}".startswith(f"Task {task_id} finished with exception:") - assert "I am failing as requested" in f"{exec_info.value}" await _assert_task_removed(async_client, task_id, router_prefix) diff --git a/packages/service-library/tests/long_running_tasks/test_long_running_tasks_task.py b/packages/service-library/tests/long_running_tasks/test_long_running_tasks_task.py index 0cd0a1676cf7..6d3b9c837f26 100644 --- a/packages/service-library/tests/long_running_tasks/test_long_running_tasks_task.py +++ b/packages/service-library/tests/long_running_tasks/test_long_running_tasks_task.py @@ -21,7 +21,6 @@ from servicelib.long_running_tasks._models import ( ProgressPercent, TaskProgress, - TaskResult, TaskStatus, ) from servicelib.long_running_tasks._task import TasksManager, start_task @@ -108,8 +107,6 @@ async def test_task_is_auto_removed( tasks_manager.get_task_status(task_id, with_task_context=None) with pytest.raises(TaskNotFoundError): tasks_manager.get_task_result(task_id, with_task_context=None) - with pytest.raises(TaskNotFoundError): - tasks_manager.get_task_result_old(task_id) async def test_checked_task_is_not_auto_removed(tasks_manager: TasksManager): @@ -156,9 +153,6 @@ async def test_get_result_of_unfinished_task_raises(tasks_manager: TasksManager) with pytest.raises(TaskNotCompletedError): tasks_manager.get_task_result(task_id, with_task_context=None) - with pytest.raises(TaskNotCompletedError): - tasks_manager.get_task_result_old(task_id) - async def test_unique_task_already_running(tasks_manager: TasksManager): async def unique_task(task_progress: TaskProgress): @@ -214,13 +208,6 @@ async def test_get_result(tasks_manager: TasksManager): assert result == 42 -async def test_get_result_old(tasks_manager: TasksManager): - task_id = start_task(tasks_manager=tasks_manager, task=fast_background_task) - await asyncio.sleep(0.1) - result = tasks_manager.get_task_result_old(task_id) - assert result == TaskResult(result=42, error=None) - - async def test_get_result_missing(tasks_manager: TasksManager): with pytest.raises(TaskNotFoundError) as exec_info: tasks_manager.get_task_result("missing_task_id", with_task_context=None) @@ -238,20 +225,6 @@ async def test_get_result_finished_with_error(tasks_manager: TasksManager): tasks_manager.get_task_result(task_id, with_task_context=None) -async def test_get_result_old_finished_with_error(tasks_manager: TasksManager): - task_id = start_task(tasks_manager=tasks_manager, task=failing_background_task) - # wait for result - async for attempt in AsyncRetrying(**_RETRY_PARAMS): - with attempt: - assert tasks_manager.get_task_status(task_id, with_task_context=None).done - - task_result = tasks_manager.get_task_result_old(task_id) - assert task_result.result is None - assert task_result.error is not None - assert task_result.error.startswith(f"Task {task_id} finished with exception:") - assert "failing asap" in task_result.error - - async def test_get_result_task_was_cancelled_multiple_times( tasks_manager: TasksManager, ): @@ -270,23 +243,6 @@ async def test_get_result_task_was_cancelled_multiple_times( tasks_manager.get_task_result(task_id, with_task_context=None) -async def test_get_result_old_task_was_cancelled_multiple_times( - tasks_manager: TasksManager, -): - task_id = start_task( - tasks_manager=tasks_manager, - task=a_background_task, - raise_when_finished=False, - total_sleep=10, - ) - for _ in range(5): - await tasks_manager.cancel_task(task_id, with_task_context=None) - - task_result = tasks_manager.get_task_result_old(task_id) - assert task_result.result is None - assert task_result.error == f"Task {task_id} was cancelled before completing" - - async def test_remove_task(tasks_manager: TasksManager): task_id = start_task( tasks_manager=tasks_manager, @@ -300,8 +256,6 @@ async def test_remove_task(tasks_manager: TasksManager): tasks_manager.get_task_status(task_id, with_task_context=None) with pytest.raises(TaskNotFoundError): tasks_manager.get_task_result(task_id, with_task_context=None) - with pytest.raises(TaskNotFoundError): - tasks_manager.get_task_result_old(task_id) async def test_remove_task_with_task_context(tasks_manager: TasksManager): diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_utils.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_utils.py index 93a3b1d69237..af3c094a57ee 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_utils.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_events_utils.py @@ -20,10 +20,7 @@ from models_library.user_preferences import FrontendUserPreference from models_library.users import UserID from servicelib.fastapi.http_client_thin import BaseHttpClientError -from servicelib.fastapi.long_running_tasks.client import ( - ProgressCallback, - TaskClientResultError, -) +from servicelib.fastapi.long_running_tasks.client import ProgressCallback from servicelib.fastapi.long_running_tasks.server import TaskProgress from servicelib.logging_utils import log_context from servicelib.rabbitmq import RabbitMQClient @@ -138,7 +135,7 @@ async def service_remove_containers( await sidecars_client.stop_service( scheduler_data.endpoint, progress_callback=progress_callback ) - except (BaseHttpClientError, TaskClientResultError) as e: + except BaseHttpClientError as e: _logger.info( ( "Could not remove service containers for %s. " @@ -373,7 +370,7 @@ async def attempt_pod_removal_and_data_saving( scheduler_data.dynamic_sidecar.were_state_and_outputs_saved = True _logger.info("dynamic-sidecar saved: state and output ports") - except (BaseHttpClientError, TaskClientResultError) as e: + except BaseHttpClientError as e: _logger.error( # noqa: TRY400 ( "Could not contact dynamic-sidecar to save service " diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/nodeports.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/nodeports.py index db074ac70714..7e6f6c7b638d 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/nodeports.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/nodeports.py @@ -276,6 +276,7 @@ async def _get_data_from_port( archive_files: set[Path] if _is_zip_file(downloaded_file): + prunable_folder = PrunableFolder(final_path.parent) with log_context( _logger, logging.DEBUG, @@ -294,6 +295,7 @@ async def _get_data_from_port( else: # move archive to directory as is final_path = final_path / downloaded_file.name + prunable_folder = PrunableFolder(final_path.parent) with log_context( _logger, logging.DEBUG, f"moving {downloaded_file} to {final_path}" @@ -305,7 +307,7 @@ async def _get_data_from_port( # NOTE: after the port content changes, make sure old files # which are no longer part of the port, are removed - PrunableFolder(final_path).prune(exclude=archive_files) + prunable_folder.prune(exclude=archive_files) else: transferred_bytes = sys.getsizeof(port_data) diff --git a/services/dynamic-sidecar/tests/unit/test_api_rest_containers.py b/services/dynamic-sidecar/tests/unit/test_api_rest_containers.py index 182743dca578..0731009a380d 100644 --- a/services/dynamic-sidecar/tests/unit/test_api_rest_containers.py +++ b/services/dynamic-sidecar/tests/unit/test_api_rest_containers.py @@ -124,8 +124,7 @@ async def _start_containers( response = await test_client.get(f"/task/{task_id}/result") assert response.status_code == status.HTTP_200_OK result_response = response.json() - assert result_response["error"] is None - response_containers = result_response["result"] + response_containers = result_response shared_store: SharedStore = test_client.application.state.shared_store container_names = shared_store.container_names diff --git a/services/dynamic-sidecar/tests/unit/test_api_rest_containers_long_running_tasks.py b/services/dynamic-sidecar/tests/unit/test_api_rest_containers_long_running_tasks.py index f65a624459d0..75677e1d7f73 100644 --- a/services/dynamic-sidecar/tests/unit/test_api_rest_containers_long_running_tasks.py +++ b/services/dynamic-sidecar/tests/unit/test_api_rest_containers_long_running_tasks.py @@ -30,7 +30,6 @@ from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict from servicelib.fastapi.long_running_tasks.client import ( Client, - TaskClientResultError, TaskId, periodic_task_result, ) @@ -46,7 +45,10 @@ from simcore_service_dynamic_sidecar.models.shared_store import SharedStore from simcore_service_dynamic_sidecar.modules.inputs import enable_inputs_pulling from simcore_service_dynamic_sidecar.modules.outputs._context import OutputsContext -from simcore_service_dynamic_sidecar.modules.outputs._manager import OutputsManager +from simcore_service_dynamic_sidecar.modules.outputs._manager import ( + OutputsManager, + UploadPortsFailedError, +) FAST_STATUS_POLL: Final[float] = 0.1 CREATE_SERVICE_CONTAINERS_TIMEOUT: Final[float] = 60 @@ -682,7 +684,7 @@ async def _test_code() -> None: if not mock_port_keys: await _test_code() else: - with pytest.raises(TaskClientResultError) as exec_info: + with pytest.raises(UploadPortsFailedError) as exec_info: await _test_code() assert f"the node id {missing_node_uuid} was not found" in f"{exec_info.value}" diff --git a/services/dynamic-sidecar/tests/unit/test_api_rest_workflow_service_metrics.py b/services/dynamic-sidecar/tests/unit/test_api_rest_workflow_service_metrics.py index 9c760ad06b41..b276f00cb2c7 100644 --- a/services/dynamic-sidecar/tests/unit/test_api_rest_workflow_service_metrics.py +++ b/services/dynamic-sidecar/tests/unit/test_api_rest_workflow_service_metrics.py @@ -34,7 +34,6 @@ from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict from servicelib.fastapi.long_running_tasks.client import ( Client, - TaskClientResultError, TaskId, periodic_task_result, ) @@ -262,7 +261,7 @@ async def test_user_services_fail_to_start( with_compose_down: bool, mock_user_services_fail_to_start: None, ): - with pytest.raises(TaskClientResultError): + with pytest.raises(RuntimeError): async with periodic_task_result( client=client, task_id=await _get_task_id_create_service_containers( @@ -318,7 +317,7 @@ async def test_user_services_fail_to_stop_or_save_data( # in case of manual intervention multiple stops will be sent _EXPECTED_STOP_MESSAGES = 4 for _ in range(_EXPECTED_STOP_MESSAGES): - with pytest.raises(TaskClientResultError): + with pytest.raises(RuntimeError): async with periodic_task_result( client=client, task_id=await _get_task_id_docker_compose_down(httpx_async_client),