From dc3275f74e21af5eb5ff6b4a21701c624c9ee1af Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Mon, 18 Nov 2024 13:28:16 +0100 Subject: [PATCH 1/8] fix unused imports --- .../simcore_service_director_v2/api/errors/validation_error.py | 2 -- .../src/simcore_service_director_v2/utils/osparc_variables.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/services/director-v2/src/simcore_service_director_v2/api/errors/validation_error.py b/services/director-v2/src/simcore_service_director_v2/api/errors/validation_error.py index b3509cbbec9..cbdc2243701 100644 --- a/services/director-v2/src/simcore_service_director_v2/api/errors/validation_error.py +++ b/services/director-v2/src/simcore_service_director_v2/api/errors/validation_error.py @@ -1,5 +1,3 @@ -from typing import Union - from fastapi.encoders import jsonable_encoder from fastapi.exceptions import RequestValidationError from fastapi.openapi.constants import REF_PREFIX diff --git a/services/director-v2/src/simcore_service_director_v2/utils/osparc_variables.py b/services/director-v2/src/simcore_service_director_v2/utils/osparc_variables.py index 6704c8369ef..2715858965b 100644 --- a/services/director-v2/src/simcore_service_director_v2/utils/osparc_variables.py +++ b/services/director-v2/src/simcore_service_director_v2/utils/osparc_variables.py @@ -4,7 +4,7 @@ from typing import Any, Final, NamedTuple, TypeAlias from models_library.utils.specs_substitution import SubstitutionValue -from pydantic import NonNegativeInt, TypeAdapter +from pydantic import NonNegativeInt from servicelib.utils import logged_gather ContextDict: TypeAlias = dict[str, Any] From 77c57623a94d893bfd080fdcee147e5154ba31b1 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Mon, 18 Nov 2024 13:48:52 +0100 Subject: [PATCH 2/8] fix field shallow copy --- packages/models-library/src/models_library/clusters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/models-library/src/models_library/clusters.py b/packages/models-library/src/models_library/clusters.py index 07a5f0dc6d9..e2bb45f50ca 100644 --- a/packages/models-library/src/models_library/clusters.py +++ b/packages/models-library/src/models_library/clusters.py @@ -227,7 +227,7 @@ def check_owner_has_access_rights(self: Self) -> Self: owner_gid = self.owner # check owner is in the access rights, if not add it - access_rights = self.access_rights.copy() + access_rights = dict(self.access_rights) if owner_gid not in access_rights: access_rights[owner_gid] = ( CLUSTER_USER_RIGHTS if is_default_cluster else CLUSTER_ADMIN_RIGHTS From 09420c6599ff057ec3c204613b0d284cacc4255a Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Mon, 18 Nov 2024 13:50:10 +0100 Subject: [PATCH 3/8] fix non-iterable --- .../pytest_simcore/helpers/httpx_calls_capture_parameters.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/pytest-simcore/src/pytest_simcore/helpers/httpx_calls_capture_parameters.py b/packages/pytest-simcore/src/pytest_simcore/helpers/httpx_calls_capture_parameters.py index 6c1a00c2302..ecfc8999aa9 100644 --- a/packages/pytest-simcore/src/pytest_simcore/helpers/httpx_calls_capture_parameters.py +++ b/packages/pytest-simcore/src/pytest_simcore/helpers/httpx_calls_capture_parameters.py @@ -66,9 +66,9 @@ def regex_pattern(self) -> str: if self.oneOf: msg = "Current version cannot compute regex patterns in case of oneOf. Please go ahead and implement it yourself." raise NotImplementedError(msg) - if self.anyOf: + if self.anyOf is not None: return "|".join([elm.regex_pattern for elm in self.anyOf]) - if self.allOf: + if self.allOf is not None: return "&".join([elm.regex_pattern for elm in self.allOf]) # now deal with non-recursive cases From 8d87e8ce0c41e035e45685bffd32c39af5b65a83 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Mon, 18 Nov 2024 14:36:24 +0100 Subject: [PATCH 4/8] remove unused code field --- packages/aws-library/src/aws_library/s3/_errors.py | 5 ----- packages/common-library/tests/test_errors_classes.py | 2 -- .../src/dask_task_models_library/container_tasks/errors.py | 4 +--- .../src/simcore_sdk/node_ports_v2/port_validation.py | 2 -- .../src/simcore_service_director_v2/core/errors.py | 4 ---- .../modules/dynamic_sidecar/errors.py | 1 - .../src/simcore_service_dynamic_scheduler/core/errors.py | 2 +- .../src/simcore_service_dynamic_sidecar/core/errors.py | 2 +- .../modules/user_services_preferences/_errors.py | 2 +- .../simcore_service_webserver/studies_dispatcher/_errors.py | 4 ---- 10 files changed, 4 insertions(+), 24 deletions(-) diff --git a/packages/aws-library/src/aws_library/s3/_errors.py b/packages/aws-library/src/aws_library/s3/_errors.py index d14105dbd30..3bafa217257 100644 --- a/packages/aws-library/src/aws_library/s3/_errors.py +++ b/packages/aws-library/src/aws_library/s3/_errors.py @@ -10,25 +10,20 @@ class S3NotConnectedError(S3RuntimeError): class S3AccessError(S3RuntimeError): - code = "s3_access.error" # type: ignore[assignment] msg_template: str = "Unexpected error while accessing S3 backend" class S3BucketInvalidError(S3AccessError): - code = "s3_bucket.invalid_error" # type: ignore[assignment] msg_template: str = "The bucket '{bucket}' is invalid" class S3KeyNotFoundError(S3AccessError): - code = "s3_key.not_found_error" # type: ignore[assignment] msg_template: str = "The file {key} in {bucket} was not found" class S3UploadNotFoundError(S3AccessError): - code = "s3_upload.not_found_error" # type: ignore[assignment] msg_template: str = "The upload for {key} in {bucket} was not found" class S3DestinationNotEmptyError(S3AccessError): - code = "s3_destination.not_empty_error" # type: ignore[assignment] msg_template: str = "The destination {dst_prefix} is not empty" diff --git a/packages/common-library/tests/test_errors_classes.py b/packages/common-library/tests/test_errors_classes.py index 3be2532f1ab..efe4c44b86e 100644 --- a/packages/common-library/tests/test_errors_classes.py +++ b/packages/common-library/tests/test_errors_classes.py @@ -49,12 +49,10 @@ class MyValueError(MyBaseError, ValueError): assert f"{error}" == "Wrong value 42" class MyTypeError(MyBaseError, TypeError): - code = "i_want_this" msg_template = "Wrong type {type}" error = MyTypeError(type="int") - assert error.code == "i_want_this" assert f"{error}" == "Wrong type int" diff --git a/packages/dask-task-models-library/src/dask_task_models_library/container_tasks/errors.py b/packages/dask-task-models-library/src/dask_task_models_library/container_tasks/errors.py index f0a6813ba15..1597ddfb6f4 100644 --- a/packages/dask-task-models-library/src/dask_task_models_library/container_tasks/errors.py +++ b/packages/dask-task-models-library/src/dask_task_models_library/container_tasks/errors.py @@ -5,16 +5,14 @@ class TaskValueError(OsparcErrorMixin, ValueError): - code = "task.value_error" # type: ignore[assignment] + ... class TaskCancelledError(OsparcErrorMixin, RuntimeError): - code = "task.cancelled_error" # type: ignore[assignment] msg_template = "The task was cancelled" class ServiceRuntimeError(OsparcErrorMixin, RuntimeError): - code = "service.runtime_error" # type: ignore[assignment] msg_template = ( "The service {service_key}:{service_version}" " running in container {container_id} failed with code" diff --git a/packages/simcore-sdk/src/simcore_sdk/node_ports_v2/port_validation.py b/packages/simcore-sdk/src/simcore_sdk/node_ports_v2/port_validation.py index b33e677c0bf..c6596e669e9 100644 --- a/packages/simcore-sdk/src/simcore_sdk/node_ports_v2/port_validation.py +++ b/packages/simcore-sdk/src/simcore_sdk/node_ports_v2/port_validation.py @@ -23,7 +23,6 @@ class PortValueError(OsparcErrorMixin, ValueError): - code = "port_validation.schema_error" # type: ignore msg_template = "Invalid value in port {port_key!r}: {schema_error_message}" # pylint: disable=useless-super-delegation @@ -38,7 +37,6 @@ def __init__(self, *, port_key: str, schema_error: JsonSchemaValidationError): class PortUnitError(OsparcErrorMixin, ValueError): - code = "port_validation.unit_error" # type: ignore msg_template = "Invalid unit in port {port_key!r}: {pint_error_msg}" # pylint: disable=useless-super-delegation diff --git a/services/director-v2/src/simcore_service_director_v2/core/errors.py b/services/director-v2/src/simcore_service_director_v2/core/errors.py index 213cd4744bf..65af83fa28f 100644 --- a/services/director-v2/src/simcore_service_director_v2/core/errors.py +++ b/services/director-v2/src/simcore_service_director_v2/core/errors.py @@ -167,8 +167,6 @@ def get_errors(self) -> list[ErrorDict]: class MissingComputationalResourcesError(TaskSchedulingError): """A task cannot be scheduled because the cluster does not have the required resources""" - code = "scheduler_error.missing_resources" - def __init__(self, project_id: ProjectID, node_id: NodeID, msg: str | None = None): super().__init__(project_id, node_id, msg=msg) @@ -176,8 +174,6 @@ def __init__(self, project_id: ProjectID, node_id: NodeID, msg: str | None = Non class InsuficientComputationalResourcesError(TaskSchedulingError): """A task cannot be scheduled because the cluster does not have *enough* of the required resources""" - code = "scheduler_error.insuficient_resources" - def __init__(self, project_id: ProjectID, node_id: NodeID, msg: str | None = None): super().__init__(project_id, node_id, msg=msg) diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/errors.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/errors.py index 8b40a4e0f35..e3d67da68aa 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/errors.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/errors.py @@ -40,5 +40,4 @@ class LegacyServiceIsNotSupportedError(DirectorError): class UnexpectedContainerStatusError(OsparcErrorMixin, DynamicSidecarError): - code = "dynamic_sidecar.container_status" # type: ignore msg_template = "Unexpected status from containers: {containers_with_error}" diff --git a/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/core/errors.py b/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/core/errors.py index 2677b7bc370..0dd4b43e4bd 100644 --- a/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/core/errors.py +++ b/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/core/errors.py @@ -2,4 +2,4 @@ class BaseDynamicSchedulerError(OsparcErrorMixin, ValueError): - code = "simcore.service.dynamic.scheduler" # type:ignore[assignment] + ... diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py index 636260814a1..bd74b68dfb7 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py @@ -36,7 +36,7 @@ def __init__(self, message: str, status_code: int) -> None: class BaseError(OsparcErrorMixin, BaseDynamicSidecarError): - code = "dy_sidecar.error" # type: ignore[assignment] + ... class ContainerExecContainerNotFoundError(BaseError): diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/user_services_preferences/_errors.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/user_services_preferences/_errors.py index b2c4a327c83..278ad52b04d 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/user_services_preferences/_errors.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/user_services_preferences/_errors.py @@ -2,7 +2,7 @@ class BaseServicesPreferencesError(OsparcErrorMixin, Exception): - code = "dynamic_sidecar.user_service_preferences" # type: ignore[assignment] + ... class DestinationIsNotADirectoryError(BaseServicesPreferencesError): diff --git a/services/web/server/src/simcore_service_webserver/studies_dispatcher/_errors.py b/services/web/server/src/simcore_service_webserver/studies_dispatcher/_errors.py index 5cff412f415..4c7c0bbce73 100644 --- a/services/web/server/src/simcore_service_webserver/studies_dispatcher/_errors.py +++ b/services/web/server/src/simcore_service_webserver/studies_dispatcher/_errors.py @@ -6,22 +6,18 @@ class StudyDispatcherError(WebServerBaseError, ValueError): class IncompatibleService(StudyDispatcherError): - code = "studies_dispatcher.incompatible_service" # type: ignore msg_template = "None of the registered services can handle '{file_type}'" class FileToLarge(StudyDispatcherError): - code = "studies_dispatcher.file_to_large" # type: ignore msg_template = "File size {file_size_in_mb} MB is over allowed limit" class ServiceNotFound(StudyDispatcherError): - code = "studies_dispatcher.service_not_found" # type: ignore msg_template = "Service {service_key}:{service_version} not found" class InvalidRedirectionParams(StudyDispatcherError): - code = "studies_dispatcher.invalid_redirection_params" # type: ignore msg_template = ( "The link you provided is invalid because it doesn't contain any information related to data or a service." " Please check the link and make sure it is correct." From c9069d2ac3942c4159f2cf6b560c9dabbbab8988 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Mon, 18 Nov 2024 15:46:44 +0100 Subject: [PATCH 5/8] fix fieldinfo access --- .../core/dynamic_services_settings/sidecar.py | 18 ++++++++----- .../core/settings.py | 26 ++++++++++--------- .../models/dynamic_services_scheduler.py | 6 ++--- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/services/director-v2/src/simcore_service_director_v2/core/dynamic_services_settings/sidecar.py b/services/director-v2/src/simcore_service_director_v2/core/dynamic_services_settings/sidecar.py index 434c3e0941f..fa0d0e670b7 100644 --- a/services/director-v2/src/simcore_service_director_v2/core/dynamic_services_settings/sidecar.py +++ b/services/director-v2/src/simcore_service_director_v2/core/dynamic_services_settings/sidecar.py @@ -2,6 +2,7 @@ import warnings from enum import Enum from pathlib import Path +from typing import Annotated from models_library.basic_types import BootModeEnum, PortInt from models_library.docker import DockerPlacementConstraint @@ -104,12 +105,17 @@ class DynamicSidecarSettings(BaseCustomSettings, MixinLoggingSettings): ), description="dynamic-sidecar's service 'endpoint_spec' with {'Mode': 'dnsrr'}", ) - DYNAMIC_SIDECAR_SC_BOOT_MODE: BootModeEnum = Field( - ..., - description="Boot mode used for the dynamic-sidecar services" - "By defaults, it uses the same boot mode set for the director-v2", - validation_alias=AliasChoices("DYNAMIC_SIDECAR_SC_BOOT_MODE", "SC_BOOT_MODE"), - ) + DYNAMIC_SIDECAR_SC_BOOT_MODE: Annotated[ + BootModeEnum, + Field( + ..., + description="Boot mode used for the dynamic-sidecar services" + "By defaults, it uses the same boot mode set for the director-v2", + validation_alias=AliasChoices( + "DYNAMIC_SIDECAR_SC_BOOT_MODE", "SC_BOOT_MODE" + ), + ), + ] DYNAMIC_SIDECAR_LOG_LEVEL: str = Field( "WARNING", diff --git a/services/director-v2/src/simcore_service_director_v2/core/settings.py b/services/director-v2/src/simcore_service_director_v2/core/settings.py index 062e1ec4d5f..30935af5d5a 100644 --- a/services/director-v2/src/simcore_service_director_v2/core/settings.py +++ b/services/director-v2/src/simcore_service_director_v2/core/settings.py @@ -4,6 +4,7 @@ import datetime from functools import cached_property +from typing import Annotated from common_library.pydantic_validators import validate_numeric_string_as_timedelta from models_library.basic_types import LogLevel, PortInt, VersionTag @@ -194,28 +195,29 @@ class AppSettings(BaseApplicationSettings, MixinLoggingSettings): ) # App modules settings --------------------- - DIRECTOR_V2_STORAGE: StorageSettings = Field( - json_schema_extra={"auto_default_from_env": True} - ) + DIRECTOR_V2_STORAGE: Annotated[ + StorageSettings, Field(json_schema_extra={"auto_default_from_env": True}) + ] DIRECTOR_V2_NODE_PORTS_STORAGE_AUTH: StorageAuthSettings | None = Field( json_schema_extra={"auto_default_from_env": True} ) - DIRECTOR_V2_CATALOG: CatalogSettings | None = Field( - json_schema_extra={"auto_default_from_env": True} - ) + DIRECTOR_V2_CATALOG: Annotated[ + CatalogSettings | None, Field(json_schema_extra={"auto_default_from_env": True}) + ] DIRECTOR_V0: DirectorV0Settings = Field( json_schema_extra={"auto_default_from_env": True} ) - DYNAMIC_SERVICES: DynamicServicesSettings = Field( - json_schema_extra={"auto_default_from_env": True} - ) + DYNAMIC_SERVICES: Annotated[ + DynamicServicesSettings, + Field(json_schema_extra={"auto_default_from_env": True}), + ] - POSTGRES: PostgresSettings = Field( - json_schema_extra={"auto_default_from_env": True} - ) + POSTGRES: Annotated[ + PostgresSettings, Field(json_schema_extra={"auto_default_from_env": True}) + ] REDIS: RedisSettings = Field(json_schema_extra={"auto_default_from_env": True}) diff --git a/services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py b/services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py index 0a2322c11c1..b4308909994 100644 --- a/services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py +++ b/services/director-v2/src/simcore_service_director_v2/models/dynamic_services_scheduler.py @@ -119,9 +119,9 @@ def create_as_initially_ok(cls) -> "Status": class DockerContainerInspect(BaseModel): - container_state: ContainerState = Field( - ..., description="current state of container" - ) + container_state: Annotated[ + ContainerState, Field(..., description="current state of container") + ] name: str = Field(..., description="docker name of the container") id: str = Field(..., description="docker id of the container") From fd29a60ccd5cd112631287ba0c222c7f0b830244 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Tue, 19 Nov 2024 08:58:54 +0100 Subject: [PATCH 6/8] silencing pylint errors --- .../modules/clusters_keeper.py | 4 +- .../modules/dask_client.py | 4 +- .../modules/dask_clients_pool.py | 4 +- .../modules/db/repositories/clusters.py | 52 ++++++++++++++----- .../modules/db/repositories/comp_runs.py | 4 +- .../simcore_service_director_v2/utils/dask.py | 4 +- .../utils/dask_client_utils.py | 12 +++-- ...t_modules_comp_scheduler_dask_scheduler.py | 14 ++--- .../core/errors.py | 6 +-- .../modules/container_utils.py | 8 +-- 10 files changed, 76 insertions(+), 36 deletions(-) diff --git a/services/director-v2/src/simcore_service_director_v2/modules/clusters_keeper.py b/services/director-v2/src/simcore_service_director_v2/modules/clusters_keeper.py index 2e62c414d86..14ed10e5703 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/clusters_keeper.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/clusters_keeper.py @@ -34,11 +34,11 @@ async def get_or_create_on_demand_cluster( ) _logger.info("received cluster: %s", returned_cluster) if returned_cluster.state is not ClusterState.RUNNING: - raise ComputationalBackendOnDemandNotReadyError( + raise ComputationalBackendOnDemandNotReadyError( # pylint: disable=unexpected-keyword-arg eta=timedelta_as_minute_second(returned_cluster.eta) ) if not returned_cluster.dask_scheduler_ready: - raise ComputationalBackendOnDemandNotReadyError( + raise ComputationalBackendOnDemandNotReadyError( # pylint: disable=unexpected-keyword-arg eta=timedelta_as_minute_second(returned_cluster.eta) ) diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dask_client.py b/services/director-v2/src/simcore_service_director_v2/modules/dask_client.py index e28e48f82f7..eb89fc965b4 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dask_client.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dask_client.py @@ -522,7 +522,9 @@ async def get_task_result(self, job_id: str) -> TaskOutputData: await task_future.result(timeout=_DASK_DEFAULT_TIMEOUT_S), ) except KeyError as exc: - raise ComputationalBackendTaskNotFoundError(job_id=job_id) from exc + raise ComputationalBackendTaskNotFoundError( # pylint: disable=unexpected-keyword-arg + job_id=job_id + ) from exc except distributed.TimeoutError as exc: raise ComputationalBackendTaskResultsNotReadyError from exc diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dask_clients_pool.py b/services/director-v2/src/simcore_service_director_v2/modules/dask_clients_pool.py index d246bb35f42..1073a0d615d 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dask_clients_pool.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dask_clients_pool.py @@ -108,7 +108,9 @@ async def _concurently_safe_acquire_client() -> DaskClient: try: dask_client = await _concurently_safe_acquire_client() except Exception as exc: - raise DaskClientAcquisisitonError(cluster=cluster, error=exc) from exc + raise DaskClientAcquisisitonError( # pylint: disable=unexpected-keyword-arg + cluster=cluster, error=exc + ) from exc try: yield dask_client diff --git a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/clusters.py b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/clusters.py index 30381110173..17998c469bc 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/clusters.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/clusters.py @@ -110,7 +110,9 @@ async def _compute_user_access_rights( solved_rights = CLUSTER_NO_RIGHTS.model_dump() for group_row in filter(lambda ugrp: ugrp[1] != GroupType.PRIMARY, user_groups): - grp_access = cluster.access_rights.get(group_row.gid, CLUSTER_NO_RIGHTS).model_dump() + grp_access = cluster.access_rights.get( + group_row.gid, CLUSTER_NO_RIGHTS + ).model_dump() for operation in ["read", "write", "delete"]: solved_rights[operation] |= grp_access[operation] return ClusterAccessRights(**solved_rights) @@ -159,7 +161,9 @@ async def get_cluster(self, user_id: UserID, cluster_id: ClusterID) -> Cluster: async with self.db_engine.acquire() as conn: clusters_list = await _clusters_from_cluster_ids(conn, {cluster_id}) if not clusters_list: - raise ClusterNotFoundError(cluster_id=cluster_id) + raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) the_cluster = clusters_list[0] access_rights = await _compute_user_access_rights( @@ -171,7 +175,9 @@ async def get_cluster(self, user_id: UserID, cluster_id: ClusterID) -> Cluster: f"{access_rights=}", ) if not access_rights.read: - raise ClusterAccessForbiddenError(cluster_id=cluster_id) + raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) return the_cluster @@ -183,7 +189,9 @@ async def update_cluster( # pylint: disable=too-many-branches conn, {cluster_id} ) if len(clusters_list) != 1: - raise ClusterNotFoundError(cluster_id=cluster_id) + raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) the_cluster = clusters_list[0] this_user_access_rights = await _compute_user_access_rights( @@ -196,12 +204,16 @@ async def update_cluster( # pylint: disable=too-many-branches ) if not this_user_access_rights.write: - raise ClusterAccessForbiddenError(cluster_id=cluster_id) + raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) if updated_cluster.owner and updated_cluster.owner != the_cluster.owner: # if the user wants to change the owner, we need more rights here if this_user_access_rights != CLUSTER_ADMIN_RIGHTS: - raise ClusterAccessForbiddenError(cluster_id=cluster_id) + raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) # ensure the new owner has admin rights, too if not updated_cluster.access_rights: @@ -225,7 +237,9 @@ async def update_cluster( # pylint: disable=too-many-branches ]: # a manager cannot change the owner abilities or create # managers/admins - raise ClusterAccessForbiddenError(cluster_id=cluster_id) + raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) resolved_access_rights.update(updated_cluster.access_rights) # ensure the user is not trying to mess around owner admin rights @@ -235,7 +249,9 @@ async def update_cluster( # pylint: disable=too-many-branches ) != CLUSTER_ADMIN_RIGHTS ): - raise ClusterAccessForbiddenError(cluster_id=cluster_id) + raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) # ok we can update now try: @@ -245,12 +261,16 @@ async def update_cluster( # pylint: disable=too-many-branches .values(to_clusters_db(updated_cluster, only_update=True)) ) except psycopg2.DatabaseError as e: - raise ClusterInvalidOperationError(cluster_id=cluster_id) from e + raise ClusterInvalidOperationError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) from e # upsert the rights if updated_cluster.access_rights: for grp, rights in resolved_access_rights.items(): insert_stmt = pg_insert(cluster_to_groups).values( - **rights.model_dump(by_alias=True), gid=grp, cluster_id=the_cluster.id + **rights.model_dump(by_alias=True), + gid=grp, + cluster_id=the_cluster.id, ) on_update_stmt = insert_stmt.on_conflict_do_update( index_elements=[ @@ -263,14 +283,18 @@ async def update_cluster( # pylint: disable=too-many-branches clusters_list = await _clusters_from_cluster_ids(conn, {cluster_id}) if not clusters_list: - raise ClusterNotFoundError(cluster_id=cluster_id) + raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) return clusters_list[0] async def delete_cluster(self, user_id: UserID, cluster_id: ClusterID) -> None: async with self.db_engine.acquire() as conn: clusters_list = await _clusters_from_cluster_ids(conn, {cluster_id}) if not clusters_list: - raise ClusterNotFoundError(cluster_id=cluster_id) + raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) the_cluster = clusters_list[0] access_rights = await _compute_user_access_rights( @@ -282,5 +306,7 @@ async def delete_cluster(self, user_id: UserID, cluster_id: ClusterID) -> None: f"{access_rights=}", ) if not access_rights.delete: - raise ClusterAccessForbiddenError(cluster_id=cluster_id) + raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) await conn.execute(sa.delete(clusters).where(clusters.c.id == cluster_id)) diff --git a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py index 9ce28bcda8d..98f15e1533a 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py @@ -117,7 +117,9 @@ async def create( row = await result.first() return CompRunsAtDB.model_validate(row) except ForeignKeyViolation as exc: - raise ClusterNotFoundError(cluster_id=cluster_id) from exc + raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg + cluster_id=cluster_id + ) from exc async def update( self, user_id: UserID, project_id: ProjectID, iteration: PositiveInt, **values diff --git a/services/director-v2/src/simcore_service_director_v2/utils/dask.py b/services/director-v2/src/simcore_service_director_v2/utils/dask.py index d76596b5bf1..3adb99b72c8 100644 --- a/services/director-v2/src/simcore_service_director_v2/utils/dask.py +++ b/services/director-v2/src/simcore_service_director_v2/utils/dask.py @@ -478,14 +478,14 @@ def check_scheduler_is_still_the_same( ): _logger.debug("current %s", f"{client.scheduler_info()=}") if "id" not in client.scheduler_info(): - raise ComputationalSchedulerChangedError( + raise ComputationalSchedulerChangedError( # pylint: disable=unexpected-keyword-arg original_scheduler_id=original_scheduler_id, current_scheduler_id="No scheduler identifier", ) current_scheduler_id = client.scheduler_info()["id"] if current_scheduler_id != original_scheduler_id: _logger.error("The computational backend changed!") - raise ComputationalSchedulerChangedError( + raise ComputationalSchedulerChangedError( # pylint: disable=unexpected-keyword-arg original_scheduler_id=original_scheduler_id, current_scheduler_id=current_scheduler_id, ) diff --git a/services/director-v2/src/simcore_service_director_v2/utils/dask_client_utils.py b/services/director-v2/src/simcore_service_director_v2/utils/dask_client_utils.py index 15e6e98dfce..43d9f4b78fb 100644 --- a/services/director-v2/src/simcore_service_director_v2/utils/dask_client_utils.py +++ b/services/director-v2/src/simcore_service_director_v2/utils/dask_client_utils.py @@ -158,13 +158,19 @@ async def _connect_with_gateway_and_create_cluster( raise ConfigurationError(msg) from exc except ValueError as exc: # this is when a 404=NotFound,422=MalformedData comes up - raise DaskClientRequestError(endpoint=endpoint, error=exc) from exc + raise DaskClientRequestError( # pylint: disable=unexpected-keyword-arg + endpoint=endpoint, error=exc + ) from exc except dask_gateway.GatewayClusterError as exc: # this is when a 409=Conflict/Cannot complete request comes up - raise DaskClusterError(endpoint=endpoint, error=exc) from exc + raise DaskClusterError( # pylint: disable=unexpected-keyword-arg + endpoint=endpoint, error=exc + ) from exc except dask_gateway.GatewayServerError as exc: # this is when a 500 comes up - raise DaskGatewayServerError(endpoint=endpoint, error=exc) from exc + raise DaskGatewayServerError( # pylint: disable=unexpected-keyword-arg + endpoint=endpoint, error=exc + ) from exc def _is_dask_scheduler(authentication: ClusterAuthentication) -> bool: diff --git a/services/director-v2/tests/unit/with_dbs/test_modules_comp_scheduler_dask_scheduler.py b/services/director-v2/tests/unit/with_dbs/test_modules_comp_scheduler_dask_scheduler.py index 495023dbda2..149a94c650e 100644 --- a/services/director-v2/tests/unit/with_dbs/test_modules_comp_scheduler_dask_scheduler.py +++ b/services/director-v2/tests/unit/with_dbs/test_modules_comp_scheduler_dask_scheduler.py @@ -1094,7 +1094,7 @@ async def test_task_progress_triggers( "backend_error", [ ComputationalBackendNotConnectedError(msg="faked disconnected backend"), - ComputationalSchedulerChangedError( + ComputationalSchedulerChangedError( # pylint: disable=unexpected-keyword-arg original_scheduler_id="some_old_scheduler_id", current_scheduler_id="some_new_scheduler_id", ), @@ -1181,7 +1181,9 @@ class RebootState: pytest.param( RebootState( dask_task_status=DaskClientTaskState.LOST, - task_result=ComputationalBackendTaskNotFoundError(job_id="fake_job_id"), + task_result=ComputationalBackendTaskNotFoundError( # pylint: disable=unexpected-keyword-arg + job_id="fake_job_id" + ), expected_task_state_group1=RunningState.FAILED, expected_task_progress_group1=1, expected_task_state_group2=RunningState.ABORTED, @@ -1217,7 +1219,7 @@ class RebootState: pytest.param( RebootState( dask_task_status=DaskClientTaskState.PENDING_OR_STARTED, - task_result=ComputationalBackendTaskResultsNotReadyError( + task_result=ComputationalBackendTaskResultsNotReadyError( # pylint: disable=unexpected-keyword-arg job_id="fake_job_id" ), expected_task_state_group1=RunningState.STARTED, @@ -1517,10 +1519,8 @@ async def test_pipeline_with_on_demand_cluster_with_not_ready_backend_waits( mocked_get_or_create_cluster: mock.Mock, faker: Faker, ): - mocked_get_or_create_cluster.side_effect = ( - ComputationalBackendOnDemandNotReadyError( - eta=faker.time_delta(datetime.timedelta(hours=1)) - ) + mocked_get_or_create_cluster.side_effect = ComputationalBackendOnDemandNotReadyError( # pylint: disable=unexpected-keyword-arg + eta=faker.time_delta(datetime.timedelta(hours=1)) ) # running the pipeline will trigger a call to the clusters-keeper assert published_project.project.prj_owner diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py index bd74b68dfb7..8f3ea3cb547 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py @@ -9,11 +9,11 @@ class BaseDynamicSidecarError(Exception): """Used as base for all exceptions""" def __init__( - self, nessage: str, status_code: int = status.HTTP_500_INTERNAL_SERVER_ERROR + self, message: str, status_code: int = status.HTTP_500_INTERNAL_SERVER_ERROR ) -> None: - self.message: str = nessage + self.message: str = message self.status_code: int = status_code - super().__init__(nessage) + super().__init__(message) class VolumeNotFoundError(BaseDynamicSidecarError): diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/container_utils.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/container_utils.py index 64b91bf938e..86c848aa6d9 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/container_utils.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/container_utils.py @@ -38,7 +38,7 @@ async def _execute_command(container_name: str, command: str | Sequence[str]) -> inspect_result: dict[str, Any] = await exec_instance.inspect() exit_code: int | None = inspect_result.get("ExitCode", None) if exit_code != 0: - raise ContainerExecCommandFailedError( + raise ContainerExecCommandFailedError( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter command=command, exit_code=exit_code, command_result=command_result ) @@ -78,9 +78,11 @@ async def run_command_in_container( ) except DockerError as e: if e.status == status.HTTP_404_NOT_FOUND: - raise ContainerExecContainerNotFoundError( + raise ContainerExecContainerNotFoundError( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter container_name=container_name ) from e raise except asyncio.TimeoutError as e: - raise ContainerExecTimeoutError(timeout=timeout, command=command) from e + raise ContainerExecTimeoutError( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter + timeout=timeout, command=command + ) from e From 884eba935b0286a66189c7be7773bd3430330564 Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Tue, 19 Nov 2024 09:06:08 +0100 Subject: [PATCH 7/8] fix field copy --- packages/models-library/src/models_library/clusters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/models-library/src/models_library/clusters.py b/packages/models-library/src/models_library/clusters.py index 82d4642717d..911b709a1f6 100644 --- a/packages/models-library/src/models_library/clusters.py +++ b/packages/models-library/src/models_library/clusters.py @@ -229,7 +229,7 @@ def check_owner_has_access_rights(self: Self) -> Self: owner_gid = self.owner # check owner is in the access rights, if not add it - access_rights = dict(self.access_rights) + access_rights = self.access_rights.copy() if owner_gid not in access_rights: access_rights[owner_gid] = ( CLUSTER_USER_RIGHTS if is_default_cluster else CLUSTER_ADMIN_RIGHTS From 29c6ca9ee4aed5cfb5af4e386bb8d3440161eadc Mon Sep 17 00:00:00 2001 From: Giancarlo Romeo Date: Tue, 19 Nov 2024 10:35:45 +0100 Subject: [PATCH 8/8] Revert "silencing pylint errors" This reverts commit fd29a60ccd5cd112631287ba0c222c7f0b830244. --- .../modules/clusters_keeper.py | 4 +- .../modules/dask_client.py | 4 +- .../modules/dask_clients_pool.py | 4 +- .../modules/db/repositories/clusters.py | 52 +++++-------------- .../modules/db/repositories/comp_runs.py | 4 +- .../simcore_service_director_v2/utils/dask.py | 4 +- .../utils/dask_client_utils.py | 12 ++--- ...t_modules_comp_scheduler_dask_scheduler.py | 14 ++--- .../core/errors.py | 6 +-- .../modules/container_utils.py | 8 ++- 10 files changed, 36 insertions(+), 76 deletions(-) diff --git a/services/director-v2/src/simcore_service_director_v2/modules/clusters_keeper.py b/services/director-v2/src/simcore_service_director_v2/modules/clusters_keeper.py index 14ed10e5703..2e62c414d86 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/clusters_keeper.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/clusters_keeper.py @@ -34,11 +34,11 @@ async def get_or_create_on_demand_cluster( ) _logger.info("received cluster: %s", returned_cluster) if returned_cluster.state is not ClusterState.RUNNING: - raise ComputationalBackendOnDemandNotReadyError( # pylint: disable=unexpected-keyword-arg + raise ComputationalBackendOnDemandNotReadyError( eta=timedelta_as_minute_second(returned_cluster.eta) ) if not returned_cluster.dask_scheduler_ready: - raise ComputationalBackendOnDemandNotReadyError( # pylint: disable=unexpected-keyword-arg + raise ComputationalBackendOnDemandNotReadyError( eta=timedelta_as_minute_second(returned_cluster.eta) ) diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dask_client.py b/services/director-v2/src/simcore_service_director_v2/modules/dask_client.py index eb89fc965b4..e28e48f82f7 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dask_client.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dask_client.py @@ -522,9 +522,7 @@ async def get_task_result(self, job_id: str) -> TaskOutputData: await task_future.result(timeout=_DASK_DEFAULT_TIMEOUT_S), ) except KeyError as exc: - raise ComputationalBackendTaskNotFoundError( # pylint: disable=unexpected-keyword-arg - job_id=job_id - ) from exc + raise ComputationalBackendTaskNotFoundError(job_id=job_id) from exc except distributed.TimeoutError as exc: raise ComputationalBackendTaskResultsNotReadyError from exc diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dask_clients_pool.py b/services/director-v2/src/simcore_service_director_v2/modules/dask_clients_pool.py index 1073a0d615d..d246bb35f42 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dask_clients_pool.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dask_clients_pool.py @@ -108,9 +108,7 @@ async def _concurently_safe_acquire_client() -> DaskClient: try: dask_client = await _concurently_safe_acquire_client() except Exception as exc: - raise DaskClientAcquisisitonError( # pylint: disable=unexpected-keyword-arg - cluster=cluster, error=exc - ) from exc + raise DaskClientAcquisisitonError(cluster=cluster, error=exc) from exc try: yield dask_client diff --git a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/clusters.py b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/clusters.py index 17998c469bc..30381110173 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/clusters.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/clusters.py @@ -110,9 +110,7 @@ async def _compute_user_access_rights( solved_rights = CLUSTER_NO_RIGHTS.model_dump() for group_row in filter(lambda ugrp: ugrp[1] != GroupType.PRIMARY, user_groups): - grp_access = cluster.access_rights.get( - group_row.gid, CLUSTER_NO_RIGHTS - ).model_dump() + grp_access = cluster.access_rights.get(group_row.gid, CLUSTER_NO_RIGHTS).model_dump() for operation in ["read", "write", "delete"]: solved_rights[operation] |= grp_access[operation] return ClusterAccessRights(**solved_rights) @@ -161,9 +159,7 @@ async def get_cluster(self, user_id: UserID, cluster_id: ClusterID) -> Cluster: async with self.db_engine.acquire() as conn: clusters_list = await _clusters_from_cluster_ids(conn, {cluster_id}) if not clusters_list: - raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterNotFoundError(cluster_id=cluster_id) the_cluster = clusters_list[0] access_rights = await _compute_user_access_rights( @@ -175,9 +171,7 @@ async def get_cluster(self, user_id: UserID, cluster_id: ClusterID) -> Cluster: f"{access_rights=}", ) if not access_rights.read: - raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterAccessForbiddenError(cluster_id=cluster_id) return the_cluster @@ -189,9 +183,7 @@ async def update_cluster( # pylint: disable=too-many-branches conn, {cluster_id} ) if len(clusters_list) != 1: - raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterNotFoundError(cluster_id=cluster_id) the_cluster = clusters_list[0] this_user_access_rights = await _compute_user_access_rights( @@ -204,16 +196,12 @@ async def update_cluster( # pylint: disable=too-many-branches ) if not this_user_access_rights.write: - raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterAccessForbiddenError(cluster_id=cluster_id) if updated_cluster.owner and updated_cluster.owner != the_cluster.owner: # if the user wants to change the owner, we need more rights here if this_user_access_rights != CLUSTER_ADMIN_RIGHTS: - raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterAccessForbiddenError(cluster_id=cluster_id) # ensure the new owner has admin rights, too if not updated_cluster.access_rights: @@ -237,9 +225,7 @@ async def update_cluster( # pylint: disable=too-many-branches ]: # a manager cannot change the owner abilities or create # managers/admins - raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterAccessForbiddenError(cluster_id=cluster_id) resolved_access_rights.update(updated_cluster.access_rights) # ensure the user is not trying to mess around owner admin rights @@ -249,9 +235,7 @@ async def update_cluster( # pylint: disable=too-many-branches ) != CLUSTER_ADMIN_RIGHTS ): - raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterAccessForbiddenError(cluster_id=cluster_id) # ok we can update now try: @@ -261,16 +245,12 @@ async def update_cluster( # pylint: disable=too-many-branches .values(to_clusters_db(updated_cluster, only_update=True)) ) except psycopg2.DatabaseError as e: - raise ClusterInvalidOperationError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) from e + raise ClusterInvalidOperationError(cluster_id=cluster_id) from e # upsert the rights if updated_cluster.access_rights: for grp, rights in resolved_access_rights.items(): insert_stmt = pg_insert(cluster_to_groups).values( - **rights.model_dump(by_alias=True), - gid=grp, - cluster_id=the_cluster.id, + **rights.model_dump(by_alias=True), gid=grp, cluster_id=the_cluster.id ) on_update_stmt = insert_stmt.on_conflict_do_update( index_elements=[ @@ -283,18 +263,14 @@ async def update_cluster( # pylint: disable=too-many-branches clusters_list = await _clusters_from_cluster_ids(conn, {cluster_id}) if not clusters_list: - raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterNotFoundError(cluster_id=cluster_id) return clusters_list[0] async def delete_cluster(self, user_id: UserID, cluster_id: ClusterID) -> None: async with self.db_engine.acquire() as conn: clusters_list = await _clusters_from_cluster_ids(conn, {cluster_id}) if not clusters_list: - raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterNotFoundError(cluster_id=cluster_id) the_cluster = clusters_list[0] access_rights = await _compute_user_access_rights( @@ -306,7 +282,5 @@ async def delete_cluster(self, user_id: UserID, cluster_id: ClusterID) -> None: f"{access_rights=}", ) if not access_rights.delete: - raise ClusterAccessForbiddenError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) + raise ClusterAccessForbiddenError(cluster_id=cluster_id) await conn.execute(sa.delete(clusters).where(clusters.c.id == cluster_id)) diff --git a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py index 98f15e1533a..9ce28bcda8d 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py @@ -117,9 +117,7 @@ async def create( row = await result.first() return CompRunsAtDB.model_validate(row) except ForeignKeyViolation as exc: - raise ClusterNotFoundError( # pylint: disable=unexpected-keyword-arg - cluster_id=cluster_id - ) from exc + raise ClusterNotFoundError(cluster_id=cluster_id) from exc async def update( self, user_id: UserID, project_id: ProjectID, iteration: PositiveInt, **values diff --git a/services/director-v2/src/simcore_service_director_v2/utils/dask.py b/services/director-v2/src/simcore_service_director_v2/utils/dask.py index 3adb99b72c8..d76596b5bf1 100644 --- a/services/director-v2/src/simcore_service_director_v2/utils/dask.py +++ b/services/director-v2/src/simcore_service_director_v2/utils/dask.py @@ -478,14 +478,14 @@ def check_scheduler_is_still_the_same( ): _logger.debug("current %s", f"{client.scheduler_info()=}") if "id" not in client.scheduler_info(): - raise ComputationalSchedulerChangedError( # pylint: disable=unexpected-keyword-arg + raise ComputationalSchedulerChangedError( original_scheduler_id=original_scheduler_id, current_scheduler_id="No scheduler identifier", ) current_scheduler_id = client.scheduler_info()["id"] if current_scheduler_id != original_scheduler_id: _logger.error("The computational backend changed!") - raise ComputationalSchedulerChangedError( # pylint: disable=unexpected-keyword-arg + raise ComputationalSchedulerChangedError( original_scheduler_id=original_scheduler_id, current_scheduler_id=current_scheduler_id, ) diff --git a/services/director-v2/src/simcore_service_director_v2/utils/dask_client_utils.py b/services/director-v2/src/simcore_service_director_v2/utils/dask_client_utils.py index 43d9f4b78fb..15e6e98dfce 100644 --- a/services/director-v2/src/simcore_service_director_v2/utils/dask_client_utils.py +++ b/services/director-v2/src/simcore_service_director_v2/utils/dask_client_utils.py @@ -158,19 +158,13 @@ async def _connect_with_gateway_and_create_cluster( raise ConfigurationError(msg) from exc except ValueError as exc: # this is when a 404=NotFound,422=MalformedData comes up - raise DaskClientRequestError( # pylint: disable=unexpected-keyword-arg - endpoint=endpoint, error=exc - ) from exc + raise DaskClientRequestError(endpoint=endpoint, error=exc) from exc except dask_gateway.GatewayClusterError as exc: # this is when a 409=Conflict/Cannot complete request comes up - raise DaskClusterError( # pylint: disable=unexpected-keyword-arg - endpoint=endpoint, error=exc - ) from exc + raise DaskClusterError(endpoint=endpoint, error=exc) from exc except dask_gateway.GatewayServerError as exc: # this is when a 500 comes up - raise DaskGatewayServerError( # pylint: disable=unexpected-keyword-arg - endpoint=endpoint, error=exc - ) from exc + raise DaskGatewayServerError(endpoint=endpoint, error=exc) from exc def _is_dask_scheduler(authentication: ClusterAuthentication) -> bool: diff --git a/services/director-v2/tests/unit/with_dbs/test_modules_comp_scheduler_dask_scheduler.py b/services/director-v2/tests/unit/with_dbs/test_modules_comp_scheduler_dask_scheduler.py index 149a94c650e..495023dbda2 100644 --- a/services/director-v2/tests/unit/with_dbs/test_modules_comp_scheduler_dask_scheduler.py +++ b/services/director-v2/tests/unit/with_dbs/test_modules_comp_scheduler_dask_scheduler.py @@ -1094,7 +1094,7 @@ async def test_task_progress_triggers( "backend_error", [ ComputationalBackendNotConnectedError(msg="faked disconnected backend"), - ComputationalSchedulerChangedError( # pylint: disable=unexpected-keyword-arg + ComputationalSchedulerChangedError( original_scheduler_id="some_old_scheduler_id", current_scheduler_id="some_new_scheduler_id", ), @@ -1181,9 +1181,7 @@ class RebootState: pytest.param( RebootState( dask_task_status=DaskClientTaskState.LOST, - task_result=ComputationalBackendTaskNotFoundError( # pylint: disable=unexpected-keyword-arg - job_id="fake_job_id" - ), + task_result=ComputationalBackendTaskNotFoundError(job_id="fake_job_id"), expected_task_state_group1=RunningState.FAILED, expected_task_progress_group1=1, expected_task_state_group2=RunningState.ABORTED, @@ -1219,7 +1217,7 @@ class RebootState: pytest.param( RebootState( dask_task_status=DaskClientTaskState.PENDING_OR_STARTED, - task_result=ComputationalBackendTaskResultsNotReadyError( # pylint: disable=unexpected-keyword-arg + task_result=ComputationalBackendTaskResultsNotReadyError( job_id="fake_job_id" ), expected_task_state_group1=RunningState.STARTED, @@ -1519,8 +1517,10 @@ async def test_pipeline_with_on_demand_cluster_with_not_ready_backend_waits( mocked_get_or_create_cluster: mock.Mock, faker: Faker, ): - mocked_get_or_create_cluster.side_effect = ComputationalBackendOnDemandNotReadyError( # pylint: disable=unexpected-keyword-arg - eta=faker.time_delta(datetime.timedelta(hours=1)) + mocked_get_or_create_cluster.side_effect = ( + ComputationalBackendOnDemandNotReadyError( + eta=faker.time_delta(datetime.timedelta(hours=1)) + ) ) # running the pipeline will trigger a call to the clusters-keeper assert published_project.project.prj_owner diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py index 8f3ea3cb547..bd74b68dfb7 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/errors.py @@ -9,11 +9,11 @@ class BaseDynamicSidecarError(Exception): """Used as base for all exceptions""" def __init__( - self, message: str, status_code: int = status.HTTP_500_INTERNAL_SERVER_ERROR + self, nessage: str, status_code: int = status.HTTP_500_INTERNAL_SERVER_ERROR ) -> None: - self.message: str = message + self.message: str = nessage self.status_code: int = status_code - super().__init__(message) + super().__init__(nessage) class VolumeNotFoundError(BaseDynamicSidecarError): diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/container_utils.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/container_utils.py index 86c848aa6d9..64b91bf938e 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/container_utils.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/container_utils.py @@ -38,7 +38,7 @@ async def _execute_command(container_name: str, command: str | Sequence[str]) -> inspect_result: dict[str, Any] = await exec_instance.inspect() exit_code: int | None = inspect_result.get("ExitCode", None) if exit_code != 0: - raise ContainerExecCommandFailedError( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter + raise ContainerExecCommandFailedError( command=command, exit_code=exit_code, command_result=command_result ) @@ -78,11 +78,9 @@ async def run_command_in_container( ) except DockerError as e: if e.status == status.HTTP_404_NOT_FOUND: - raise ContainerExecContainerNotFoundError( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter + raise ContainerExecContainerNotFoundError( container_name=container_name ) from e raise except asyncio.TimeoutError as e: - raise ContainerExecTimeoutError( # pylint: disable=unexpected-keyword-arg,no-value-for-parameter - timeout=timeout, command=command - ) from e + raise ContainerExecTimeoutError(timeout=timeout, command=command) from e