@@ -83,7 +83,8 @@ def log_platform_event(
8383def get_platform (
8484 task_conf : Optional [str ] = None ,
8585 task_name : str = UNKNOWN_TASK ,
86- bad_hosts : Optional [Set [str ]] = None
86+ bad_hosts : Optional [Set [str ]] = None ,
87+ evaluated_host : Optional [str ] = None ,
8788) -> Dict [str , Any ]:
8889 ...
8990
@@ -92,7 +93,8 @@ def get_platform(
9293def get_platform (
9394 task_conf : Union [dict , 'OrderedDictWithDefaults' ],
9495 task_name : str = UNKNOWN_TASK ,
95- bad_hosts : Optional [Set [str ]] = None
96+ bad_hosts : Optional [Set [str ]] = None ,
97+ evaluated_host : Optional [str ] = None ,
9698) -> Optional [Dict [str , Any ]]:
9799 ...
98100
@@ -108,7 +110,8 @@ def get_platform(
108110def get_platform (
109111 task_conf : Union [str , dict , 'OrderedDictWithDefaults' , None ] = None ,
110112 task_name : str = UNKNOWN_TASK ,
111- bad_hosts : Optional [Set [str ]] = None
113+ bad_hosts : Optional [Set [str ]] = None ,
114+ evaluated_host : Optional [str ] = None ,
112115) -> Optional [Dict [str , Any ]]:
113116 """Get a platform.
114117
@@ -121,6 +124,7 @@ def get_platform(
121124 task_name: Help produce more helpful error messages.
122125 bad_hosts: A set of hosts known to be unreachable (had an ssh 255
123126 error)
127+ evaluated_host: Host name evaluated from platform subshell.
124128
125129 Returns:
126130 platform: A platform definition dictionary. Uses either
@@ -169,6 +173,7 @@ def get_platform(
169173 glbl_cfg ().get (['platforms' ]),
170174 task_job_section ,
171175 task_remote_section ,
176+ evaluated_host ,
172177 ),
173178 bad_hosts = bad_hosts ,
174179 )
@@ -330,7 +335,8 @@ def get_platform_from_group(
330335def platform_name_from_job_info (
331336 platforms : Union [dict , 'OrderedDictWithDefaults' ],
332337 job : Dict [str , Any ],
333- remote : Dict [str , Any ]
338+ remote : Dict [str , Any ],
339+ evaluated_host : Optional [str ] = None ,
334340) -> str :
335341 """
336342 Find out which job platform to use given a list of possible platforms
@@ -385,6 +391,7 @@ def platform_name_from_job_info(
385391 job: Workflow config [runtime][TASK][job] section.
386392 remote: Workflow config [runtime][TASK][remote] section.
387393 platforms: Dictionary containing platform definitions.
394+ evaluated_host: Host is the result of evaluating a subshell.
388395
389396 Returns:
390397 platform: string representing a platform from the global config.
@@ -422,7 +429,9 @@ def platform_name_from_job_info(
422429
423430 # NOTE: Do NOT use .get() on OrderedDictWithDefaults -
424431 # https://github.com/cylc/cylc-flow/pull/4975
425- if 'host' in remote and remote ['host' ]:
432+ if evaluated_host :
433+ task_host = evaluated_host
434+ elif 'host' in remote and remote ['host' ]:
426435 task_host = remote ['host' ]
427436 else :
428437 task_host = 'localhost'
0 commit comments