Skip to content

Commit

Permalink
response to review
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Apr 11, 2023
1 parent 2be1bc1 commit d56e9dd
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
16 changes: 12 additions & 4 deletions cylc/flow/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,20 @@ def __str__(self):


class NoPlatformsError(CylcError):
"""None of the platforms of a given group were reachable."""
def __init__(self, platform_group):
self.platform_group = platform_group
"""None of the platforms of a given set were reachable.
Instatiation args:
identity: The name of the platform group or install target
_type: Whether the set of platforms is a platform group or an
install target
"""
def __init__(self, identity: str, set_type: str = 'group'):
self.identity = identity
self.type = set_type

def __str__(self):
return f'Unable to find a platform from group {self.platform_group}.'
return (
f'Unable to find a platform from {self.type} {self.identity}.')


class CylcVersionError(CylcError):
Expand Down
2 changes: 1 addition & 1 deletion cylc/flow/platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from copy import deepcopy
from typing import (
TYPE_CHECKING, Any, Dict, Iterable,
List, Optional, Set, Tuple, Union, overload
List, Optional, Set, Union, overload
)

from cylc.flow import LOG
Expand Down
20 changes: 11 additions & 9 deletions cylc/flow/task_remote_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@
from subprocess import Popen, PIPE, DEVNULL
import tarfile
from time import sleep, time
from typing import Any, Deque, Dict, TYPE_CHECKING, List, NamedTuple, Tuple
from typing import (
Any, Deque, Dict, TYPE_CHECKING, List, NamedTuple, Set, Tuple)

from cylc.flow import LOG
from cylc.flow.exceptions import (
PlatformError, PlatformLookupError, NoHostsError
PlatformError, PlatformLookupError, NoHostsError, NoPlatformsError
)
import cylc.flow.flags
from cylc.flow.hostuserutil import is_remote_host
Expand Down Expand Up @@ -290,7 +291,7 @@ def construct_remote_tidy_ssh_cmd(
@staticmethod
def _get_remote_tidy_targets(
platform_names: List[str],
install_targets: List[str]
install_targets: Set[str]
) -> Dict[str, List[Dict[str, Any]]]:
"""Finds valid platforms for install targets, warns about in invalid
install targets.
Expand All @@ -316,10 +317,6 @@ def _get_remote_tidy_targets(
if unreachable_targets:
msg = 'No platforms available to remote tidy install targets:'
for unreachable_target in unreachable_targets:
msg = (
'Unable to tidy the following install targets'
' because no matching platform was found:'
)
msg += f'\n * {unreachable_target}'
LOG.error(msg)

Expand All @@ -346,10 +343,10 @@ def remote_tidy(self) -> None:

# Issue all SSH commands in parallel
queue: Deque[RemoteTidyQueueTuple] = deque()
for install_target in install_targets_map.keys():
for install_target, platforms in install_targets_map.items():
if install_target == get_localhost_install_target():
continue
for platform in install_targets_map[install_target]:
for platform in platforms:
try:
cmd, host = self.construct_remote_tidy_ssh_cmd(platform)
except NoHostsError as exc:
Expand All @@ -372,6 +369,11 @@ def remote_tidy(self) -> None:
)
)
break
else:
LOG.error(
# f'Unable to clean install target {install_target}',
NoPlatformsError(install_target, 'install target')
)
# Wait for commands to complete for a max of 10 seconds
timeout = time() + 10.0
while queue and time() < timeout:
Expand Down

0 comments on commit d56e9dd

Please sign in to comment.