Skip to content

Commit dbdce6d

Browse files
committed
Tidy
1 parent 82c22b9 commit dbdce6d

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

cylc/flow/platforms.py

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ def get_platform(
125125
Returns:
126126
platform: A platform definition dictionary. Uses either
127127
get_platform() or platform_name_from_job_info(), but to the
128-
user these look the same.
128+
user these look the same. This will be None if the platform
129+
definition uses a subshell.
129130
130131
Raises:
131132
NoPlatformsError:
@@ -142,7 +143,7 @@ def get_platform(
142143

143144
# NOTE: Do NOT use .get() on OrderedDictWithDefaults -
144145
# https://github.com/cylc/cylc-flow/pull/4975
145-
elif 'platform' in task_conf and task_conf['platform']:
146+
if 'platform' in task_conf and task_conf['platform']:
146147
# Check whether task has conflicting Cylc7 items.
147148
fail_if_platform_and_host_conflict(task_conf, task_name)
148149

@@ -155,24 +156,22 @@ def get_platform(
155156
# If platform name exists and doesn't clash with Cylc7 Config items.
156157
return platform_from_name(task_conf['platform'], bad_hosts=bad_hosts)
157158

158-
else:
159-
if get_platform_deprecated_settings(task_conf) == []:
160-
# No deprecated items; platform is localhost
161-
return platform_from_name()
162-
else:
163-
# Need to calculate platform
164-
# NOTE: Do NOT use .get() on OrderedDictWithDefaults - see above
165-
task_job_section = task_conf['job'] if 'job' in task_conf else {}
166-
task_remote_section = (
167-
task_conf['remote'] if 'remote' in task_conf else {})
168-
return platform_from_name(
169-
platform_name_from_job_info(
170-
glbl_cfg().get(['platforms']),
171-
task_job_section,
172-
task_remote_section
173-
),
174-
bad_hosts=bad_hosts
175-
)
159+
if get_platform_deprecated_settings(task_conf) == []:
160+
# No deprecated items; platform is localhost
161+
return platform_from_name()
162+
163+
# Need to calculate platform
164+
# NOTE: Do NOT use .get() on OrderedDictWithDefaults - see above
165+
task_job_section = task_conf['job'] if 'job' in task_conf else {}
166+
task_remote_section = task_conf['remote'] if 'remote' in task_conf else {}
167+
return platform_from_name(
168+
platform_name_from_job_info(
169+
glbl_cfg().get(['platforms']),
170+
task_job_section,
171+
task_remote_section,
172+
),
173+
bad_hosts=bad_hosts,
174+
)
176175

177176

178177
def platform_from_name(

cylc/flow/task_job_mgr.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,23 +1239,19 @@ def _prep_submit_task_job(
12391239
itask.summary['platforms_used'][itask.submit_num] = ''
12401240
# Retry delays, needed for the try_num
12411241
self._create_job_log_path(itask)
1242+
msg = '(platform not defined)'
12421243
if isinstance(exc, NoPlatformsError):
1244+
msg = '(no platforms available)'
12431245
# Clear all hosts from all platforms in group from
12441246
# bad_hosts:
12451247
self.bad_hosts -= exc.hosts_consumed
12461248
self._set_retry_timers(itask, rtconfig)
1247-
self._prep_submit_task_job_error(
1248-
itask, '(no platforms available)', exc
1249-
)
1250-
return False
1251-
self._prep_submit_task_job_error(
1252-
itask, '(platform not defined)', exc
1253-
)
1249+
self._prep_submit_task_job_error(itask, msg, exc)
12541250
return False
1255-
else:
1256-
itask.platform = platform
1257-
# Retry delays, needed for the try_num
1258-
self._set_retry_timers(itask, rtconfig)
1251+
1252+
itask.platform = platform
1253+
# Retry delays, needed for the try_num
1254+
self._set_retry_timers(itask, rtconfig)
12591255

12601256
try:
12611257
job_conf = self._prep_submit_task_job_impl(

0 commit comments

Comments
 (0)