Skip to content

Commit

Permalink
Correct incorrect type annotation inside strategy code
Browse files Browse the repository at this point in the history
This was not causing an error in master because no uses of the
incorrectly annotated attribute (self.executors) were type checked.

This PR introduces a typed dict to represent the (single element) dictionary
used for strategy state.

(A futher tidyup could be to remove that typed dict entirely and replace with
the single value it contains, but this PR is trying to be descriptive of
existing code)

The incorrect type annotation was added in #2712
  • Loading branch information
benclifford committed Aug 11, 2023
1 parent eb7ffe9 commit 50e8e94
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions parsl/jobs/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import time
import math
import warnings
from typing import Dict, List, Optional
from typing import Dict, List, Optional, TypedDict

import parsl.jobs.job_status_poller as jsp

from parsl.executors import HighThroughputExecutor
from parsl.executors.base import ParslExecutor
from parsl.executors.status_handling import BlockProviderExecutor
from parsl.jobs.states import JobState
from parsl.process_loggers import wrap_with_logs
Expand All @@ -17,6 +16,16 @@
logger = logging.getLogger(__name__)


class ExecutorState(TypedDict):
"""Strategy relevant state for an executor
"""

idle_since: Optional[float]
"""The timestamp at which an executor became idle.
If the executor is not idle, then None.
"""


class Strategy:
"""Scaling strategy.
Expand Down Expand Up @@ -115,7 +124,7 @@ class Strategy:

def __init__(self, *, strategy: Optional[str], max_idletime: float):
"""Initialize strategy."""
self.executors: Dict[str, ParslExecutor]
self.executors: Dict[str, ExecutorState]
self.executors = {}
self.max_idletime = max_idletime

Expand Down

0 comments on commit 50e8e94

Please sign in to comment.