Skip to content

Commit

Permalink
Merge branch 'fix.platform_is_regex_remote_tidy_fail' of github.com:w…
Browse files Browse the repository at this point in the history
…xtim/cylc into fix.platform_is_regex_remote_tidy_fail

* 'fix.platform_is_regex_remote_tidy_fail' of github.com:wxtim/cylc:
  Apply suggestions from code review
  Update cylc/flow/exceptions.py
  • Loading branch information
wxtim committed Apr 17, 2023
2 parents 488bc58 + f41c478 commit d1ff32e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions cylc/flow/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ def __str__(self):
class NoPlatformsError(CylcError):
"""None of the platforms of a given set were reachable.
Instatiation args:
Args:
identity: The name of the platform group or install target
_type: Whether the set of platforms is a platform group or an
set_type: Whether the set of platforms is a platform group or an
install target
place: Where the attempt to get the platform failed.
"""
Expand Down
6 changes: 2 additions & 4 deletions cylc/flow/task_remote_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def construct_remote_tidy_ssh_cmd(

@staticmethod
def _get_remote_tidy_targets(
platform_names: List[str],
platform_names: Optional[List[str]],
install_targets: Set[str]
) -> Dict[str, List[Dict[str, Any]]]:
"""Finds valid platforms for install targets, warns about in invalid
Expand All @@ -311,9 +311,7 @@ def _get_remote_tidy_targets(

# If we couldn't find a platform for a target, we cannot tidy it -
# raise an Error:
unreachable_targets = {
t for t in install_targets if not install_targets_map.get(t)
}
unreachable_targets = install_targets.difference(install_targets_map)
if unreachable_targets:
msg = 'No platforms available to remote tidy install targets:'
for unreachable_target in unreachable_targets:
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/test_rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ def test_select_platforms_used(tmp_path):
"""
# Setup DB
db_file = tmp_path / 'db'
dao = CylcWorkflowDAO(db_file_name=db_file, create_tables=True)

# Write database with 6 tasks using 3 platforms:
platforms = ['foo', 'bar', 'bar', 'qux', 'qux', 'qux']
line = (
r" ('', '', {}, 0, 1, '', '', 0, '', '', '', 0, '', '{}', 4377, '')")
stmt = r"INSERT INTO task_jobs VALUES" + r','.join([
line.format(i, platform) for i, platform in enumerate(platforms)
])
dao.conn.execute(stmt)

# Assert that we only have 3 platforms reported by function:
assert dao.select_platforms_used() == {'bar', 'qux', 'foo'}
with CylcWorkflowDAO(db_file_name=db_file, create_tables=True) as dao:

# Write database with 6 tasks using 3 platforms:
platforms = ['foo', 'bar', 'bar', 'qux', 'qux', 'qux']
line = (
r" ('', '', {}, 0, 1, '', '', 0, '', '', '', 0, '', '{}', 4377, '')")
stmt = r"INSERT INTO task_jobs VALUES" + r','.join([
line.format(i, platform) for i, platform in enumerate(platforms)
])
dao.conn.execute(stmt)

# Assert that we only have 3 platforms reported by function:
assert dao.select_platforms_used() == {'bar', 'qux', 'foo'}
2 changes: 1 addition & 1 deletion tests/unit/test_task_remote_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_get_log_file_name(tmp_path: Path,
id='basic'
),
pytest.param(
# Two platforms share an install target. Both are reachable.
# Two platforms share an install target. Both are unreachable.
None,
['mountain_railway'],
'''
Expand Down

0 comments on commit d1ff32e

Please sign in to comment.