From 385fa3b8b14f928be841e0b06981efe0058b7ea6 Mon Sep 17 00:00:00 2001 From: Ben Clifford Date: Thu, 20 Jul 2023 12:34:33 +0200 Subject: [PATCH] Remove ExecutorStatus abstract class (#2835) This removes the ExecutorStatus abstract class, instead using its only concrete implementation PollItem everywhere that ExecutorStatus was previously used. This requires some circular imports to let type annotations work - some now annotate some things as PollItem rather than ExecutorStatus. This is done using from __future__ import annotations and import rather than from ... import ... --- parsl/dataflow/executor_status.py | 16 ---------------- parsl/dataflow/job_error_handler.py | 9 ++++++--- parsl/dataflow/job_status_poller.py | 4 ++-- parsl/dataflow/strategy.py | 6 ++++-- 4 files changed, 12 insertions(+), 23 deletions(-) delete mode 100644 parsl/dataflow/executor_status.py diff --git a/parsl/dataflow/executor_status.py b/parsl/dataflow/executor_status.py deleted file mode 100644 index e7efeed419..0000000000 --- a/parsl/dataflow/executor_status.py +++ /dev/null @@ -1,16 +0,0 @@ -import parsl - -from abc import ABCMeta, abstractmethod -from typing import Dict - - -class ExecutorStatus(metaclass=ABCMeta): - @property - @abstractmethod - def executor(self) -> "parsl.executors.base.ParslExecutor": - pass - - @property - @abstractmethod - def status(self) -> Dict[str, "parsl.providers.base.JobStatus"]: - pass diff --git a/parsl/dataflow/job_error_handler.py b/parsl/dataflow/job_error_handler.py index b0a2ad92aa..f5a59a9957 100644 --- a/parsl/dataflow/job_error_handler.py +++ b/parsl/dataflow/job_error_handler.py @@ -1,16 +1,19 @@ +from __future__ import annotations + from typing import List, Dict -from parsl.dataflow.executor_status import ExecutorStatus +import parsl.dataflow.job_status_poller as jsp + from parsl.executors.base import ParslExecutor from parsl.providers.base import JobStatus, JobState class JobErrorHandler: - def run(self, status: List[ExecutorStatus]): + def run(self, status: List[jsp.PollItem]): for es in status: self._check_irrecoverable_executor(es) - def _check_irrecoverable_executor(self, es: ExecutorStatus): + def _check_irrecoverable_executor(self, es: jsp.PollItem): if not es.executor.error_management_enabled: return es.executor.handle_errors(self, es.status) diff --git a/parsl/dataflow/job_status_poller.py b/parsl/dataflow/job_status_poller.py index b604972632..197e32ca02 100644 --- a/parsl/dataflow/job_status_poller.py +++ b/parsl/dataflow/job_status_poller.py @@ -5,7 +5,6 @@ from typing import Dict, Sequence from typing import List # noqa F401 (used in type annotation) -from parsl.dataflow.executor_status import ExecutorStatus from parsl.dataflow.job_error_handler import JobErrorHandler from parsl.dataflow.strategy import Strategy from parsl.executors.base import ParslExecutor @@ -15,10 +14,11 @@ from parsl.utils import Timer + logger = logging.getLogger(__name__) -class PollItem(ExecutorStatus): +class PollItem: def __init__(self, executor: ParslExecutor, dfk: "parsl.dataflow.dflow.DataFlowKernel"): self._executor = executor self._dfk = dfk diff --git a/parsl/dataflow/strategy.py b/parsl/dataflow/strategy.py index e84c7824bd..0511ed863b 100644 --- a/parsl/dataflow/strategy.py +++ b/parsl/dataflow/strategy.py @@ -1,10 +1,12 @@ +from __future__ import annotations import logging import time import math import warnings from typing import Dict, List, Optional -from parsl.dataflow.executor_status import ExecutorStatus +import parsl.dataflow.job_status_poller as jsp + from parsl.executors import HighThroughputExecutor from parsl.executors.base import ParslExecutor from parsl.executors.status_handling import BlockProviderExecutor @@ -134,7 +136,7 @@ def add_executors(self, executors): for executor in executors: self.executors[executor.label] = {'idle_since': None} - def _strategy_noop(self, status: List[ExecutorStatus]) -> None: + def _strategy_noop(self, status: List[jsp.PollItem]) -> None: """Do nothing. """ logger.debug("strategy_noop: doing nothing")