5656 NoPlatformsError ,
5757 PlatformError ,
5858 PlatformLookupError ,
59- WorkflowConfigError ,
6059)
6160from cylc .flow .hostuserutil import (
6261 get_host ,
7069from cylc .flow .pathutil import get_remote_workflow_run_job_dir
7170from cylc .flow .platforms import (
7271 FORBIDDEN_WITH_PLATFORM ,
72+ fail_if_platform_and_host_conflict ,
7373 get_host_from_platform ,
7474 get_install_target_from_platform ,
7575 get_localhost_install_target ,
@@ -1168,15 +1168,7 @@ def _prep_submit_task_job(
11681168 # - host exists - eval host_n
11691169 # remove at:
11701170 # Cylc8.x
1171- if (
1172- rtconfig ['platform' ] is not None and
1173- rtconfig ['remote' ]['host' ] is not None
1174- ):
1175- raise WorkflowConfigError (
1176- "A mixture of Cylc 7 (host) and Cylc 8 (platform) "
1177- "logic should not be used. In this case for the task "
1178- f"\" { itask .identity } \" the following are not compatible:\n "
1179- )
1171+ fail_if_platform_and_host_conflict (rtconfig , itask .tdef .name )
11801172
11811173 host_name , platform_name = None , None
11821174 try :
@@ -1196,37 +1188,41 @@ def _prep_submit_task_job(
11961188 )
11971189
11981190 except PlatformError as exc :
1199- itask .waiting_on_job_prep = False
1200- itask .summary ['platforms_used' ][itask .submit_num ] = ''
1201- # Retry delays, needed for the try_num
1202- self ._create_job_log_path (itask )
1203- self ._set_retry_timers (itask , rtconfig )
1204- self ._prep_submit_task_job_error (
1205- itask , '(remote host select)' , exc
1206- )
1191+ self ._prep_submit_task_job_platform_error (itask , rtconfig , exc )
12071192 return False
12081193 else :
1209- # host/platform select not ready
12101194 if host_name is None and platform_name is None :
1195+ # host/platform select not ready
12111196 return None
12121197 elif (
12131198 host_name is None
12141199 and rtconfig ['platform' ]
12151200 and rtconfig ['platform' ] != platform_name
12161201 ):
1217- LOG . debug (
1202+ msg = (
12181203 f"for task { itask .identity } : platform = "
1219- f"{ rtconfig ['platform' ]} evaluated as { platform_name } "
1204+ f"{ rtconfig ['platform' ]} evaluated as ' { platform_name } ' "
12201205 )
1221-
1206+ if not platform_name :
1207+ self ._prep_submit_task_job_platform_error (
1208+ itask , rtconfig , msg
1209+ )
1210+ return False
1211+ LOG .debug (msg )
12221212 elif (
12231213 platform_name is None
12241214 and rtconfig ['remote' ]['host' ] != host_name
12251215 ):
1226- LOG . debug (
1216+ msg = (
12271217 f"[{ itask } ] host = "
1228- f"{ rtconfig ['remote' ]['host' ]} evaluated as { host_name } "
1218+ f"{ rtconfig ['remote' ]['host' ]} evaluated as ' { host_name } ' "
12291219 )
1220+ if not host_name :
1221+ self ._prep_submit_task_job_platform_error (
1222+ itask , rtconfig , msg
1223+ )
1224+ return False
1225+ LOG .debug (msg )
12301226
12311227 try :
12321228 platform = cast (
@@ -1293,6 +1289,20 @@ def _prep_submit_task_job(
12931289 itask .local_job_file_path = local_job_file_path
12941290 return itask
12951291
1292+ def _prep_submit_task_job_platform_error (
1293+ self , itask : 'TaskProxy' , rtconfig : dict , exc : Exception | str
1294+ ):
1295+ """Helper for self._prep_submit_task_job. On platform selection error.
1296+ """
1297+ itask .waiting_on_job_prep = False
1298+ itask .summary ['platforms_used' ][itask .submit_num ] = ''
1299+ # Retry delays, needed for the try_num
1300+ self ._create_job_log_path (itask )
1301+ self ._set_retry_timers (itask , rtconfig )
1302+ self ._prep_submit_task_job_error (
1303+ itask , '(remote host select)' , exc
1304+ )
1305+
12961306 def _prep_submit_task_job_error (
12971307 self ,
12981308 itask : 'TaskProxy' ,
0 commit comments