From c70f0f9c188bb331ffe33dda48d402d31912e7dd Mon Sep 17 00:00:00 2001 From: Jae Aeich Date: Mon, 22 Jan 2024 22:30:27 +0530 Subject: [PATCH] fix: attr error --- mypy.ini | 1 - pro_wes/app.py | 4 ++-- pro_wes/ga4gh/wes/models.py | 2 +- pro_wes/ga4gh/wes/service_info.py | 2 +- pro_wes/ga4gh/wes/workflow_runs.py | 2 +- pro_wes/tasks/track_run_progress.py | 12 ++++++------ tests/ga4gh/wes/endpoints/test_service_info.py | 2 +- 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/mypy.ini b/mypy.ini index 43d8804..2ee57fc 100644 --- a/mypy.ini +++ b/mypy.ini @@ -1,5 +1,4 @@ [mypy] -disable_error_code = attr-defined [mypy-foca.*] ignore_missing_imports = True diff --git a/pro_wes/app.py b/pro_wes/app.py index 21bc254..4f0e8fb 100644 --- a/pro_wes/app.py +++ b/pro_wes/app.py @@ -29,14 +29,14 @@ def _setup_first_start(app: App) -> None: """Set up application for first start.""" with app.app.app_context(): # create storage directory - work_dir = Path(current_app.config.foca.custom.post_runs.storage_path.resolve()) + work_dir = Path(current_app.config.foca.custom.post_runs.storage_path.resolve()) # type: ignore work_dir.mkdir(parents=True, exist_ok=True) # set service info try: ServiceInfo().get_service_info() except NotFound: ServiceInfo().set_service_info( - data=current_app.config.foca.custom.service_info.dict() + data=current_app.config.foca.custom.service_info.dict() # type: ignore ) diff --git a/pro_wes/ga4gh/wes/models.py b/pro_wes/ga4gh/wes/models.py index 6cce817..0e0a32f 100644 --- a/pro_wes/ga4gh/wes/models.py +++ b/pro_wes/ga4gh/wes/models.py @@ -158,7 +158,7 @@ def json_serialized_object_field_valid( # pylint: disable=no-self-argument value does not represent an object/dictionary. """ if value == "" or value == "null" or value is None: - if field.name == "workflow_params": + if field == "workflow_params": raise ValueError("field required") return "{}" try: diff --git a/pro_wes/ga4gh/wes/service_info.py b/pro_wes/ga4gh/wes/service_info.py index f333811..47c485b 100644 --- a/pro_wes/ga4gh/wes/service_info.py +++ b/pro_wes/ga4gh/wes/service_info.py @@ -30,7 +30,7 @@ class ServiceInfo: def __init__(self) -> None: """Class constructor.""" self.config: Dict = current_app.config - self.foca_config: Config = self.config.foca + self.foca_config: Config = self.config.foca # type: ignore self.db_client_service_info: Collection = ( self.foca_config.db.dbs["runStore"].collections["service_info"].client ) diff --git a/pro_wes/ga4gh/wes/workflow_runs.py b/pro_wes/ga4gh/wes/workflow_runs.py index 894eebc..d3fd27e 100644 --- a/pro_wes/ga4gh/wes/workflow_runs.py +++ b/pro_wes/ga4gh/wes/workflow_runs.py @@ -56,7 +56,7 @@ class WorkflowRuns: def __init__(self) -> None: """Class constructor.""" self.config: Dict = current_app.config - self.foca_config: Config = current_app.config.foca + self.foca_config: Config = current_app.config.foca # type: ignore self.db_client: Collection = ( self.foca_config.db.dbs["runStore"].collections["runs"].client ) diff --git a/pro_wes/tasks/track_run_progress.py b/pro_wes/tasks/track_run_progress.py index 9d26192..351ce25 100644 --- a/pro_wes/tasks/track_run_progress.py +++ b/pro_wes/tasks/track_run_progress.py @@ -57,7 +57,7 @@ def task__track_run_progress( # pylint: disable=too-many-statements pro_wes.exceptions.EngineUnavailable: The remote service is unavailable or is not a valid WES service. """ - foca_config: Config = current_app.config.foca + foca_config: Config = current_app.config.foca # type: ignore controller_config: Dict = foca_config.custom.post_runs logger.info(f"[{self.request.id}] Start processing...") @@ -95,7 +95,7 @@ def task__track_run_progress( # pylint: disable=too-many-statements # if not isinstance(response, RunLog): # db_client.update_run_state(state=State.SYSTEM_ERROR.value) # raise EngineProblem("Did not receive expected response.") - response.pop("request", None) + response.pop("request", None) # type: ignore document: DbDocument = db_client.upsert_fields_in_root_object( root="run_log", **response.dict(), @@ -105,7 +105,7 @@ def task__track_run_progress( # pylint: disable=too-many-statements run_state: State = State.UNKNOWN attempt: int = 1 while not run_state.is_finished: - sleep(controller_config.polling_wait) + sleep(controller_config.polling_wait) # type: ignore # ensure WES endpoint is available assert document.wes_endpoint is not None, "No WES endpoint available." @@ -117,14 +117,14 @@ def task__track_run_progress( # pylint: disable=too-many-statements timeout=foca_config.custom.defaults.timeout, ) except EngineUnavailable as exc: - if attempt <= controller_config.polling_attempts: + if attempt <= controller_config.polling_attempts: # type: ignore attempt += 1 logger.warning(exc, exc_info=True) continue db_client.update_run_state(state=State.SYSTEM_ERROR.value) raise if not isinstance(response, RunStatus): - if attempt <= controller_config.polling_attempts: + if attempt <= controller_config.polling_attempts: # type: ignore attempt += 1 logger.warning(f"Received error response: {response}") continue @@ -148,7 +148,7 @@ def task__track_run_progress( # pylint: disable=too-many-statements # if not isinstance(response, RunLog): # db_client.update_run_state(state=State.SYSTEM_ERROR.value) # raise EngineProblem("Did not receive expected response.") - response.pop("request", None) + response.pop("request", None) # type: ignore document = db_client.upsert_fields_in_root_object( root="run_log", **dict(response), diff --git a/tests/ga4gh/wes/endpoints/test_service_info.py b/tests/ga4gh/wes/endpoints/test_service_info.py index db68dc9..7d94ba5 100644 --- a/tests/ga4gh/wes/endpoints/test_service_info.py +++ b/tests/ga4gh/wes/endpoints/test_service_info.py @@ -11,7 +11,7 @@ from unittest.mock import MagicMock -from pro_wes.ga4gh.wes.service_info import RegisterServiceInfo +from pro_wes.ga4gh.wes.service_info import RegisterServiceInfo # type: ignore from pro_wes.exceptions import ( NotFound, ValidationError,