Skip to content

Commit 6743c04

Browse files
authored
Merge pull request #6941 from cylc/8.5.x-sync
🤖 Merge 8.5.x-sync into master
2 parents f1fd419 + 0fa3b0c commit 6743c04

File tree

12 files changed

+91
-40
lines changed

12 files changed

+91
-40
lines changed

changes.d/6848.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow `flow.cylc[runtime][<task>]platform` setting to have a prefix/suffix around a subshell expression.

changes.d/6940.fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed a scheduler crash that could occur after re-running a task in skip mode.

cylc/flow/cfgspec/globalcfg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,8 @@ def default_for(
10461046
''')
10471047
Conf('process check timeout', VDR.V_INTERVAL, DurationFloat(10),
10481048
desc='''
1049-
Maximum time for the `cylc play` and `cylc vr` commands to wait
1049+
Maximum time for the ``cylc play`` and ``cylc vr`` commands
1050+
to wait
10501051
for a remote process that checks if an unresponsive scheduler
10511052
is still alive (for workflows with existing contact files).
10521053

cylc/flow/cfgspec/workflow.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,6 +1211,7 @@ def get_script_common_text(this: str, example: Optional[str] = None):
12111211
12121212
# run a command to select the platform (or platform group):
12131213
platform = $(select-platform)
1214+
platform = prefix-$(select-platform)-suffix
12141215
12151216
.. versionadded:: 8.0.0
12161217
''')

cylc/flow/platforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
# Regex to check whether a string is a command
5959
HOST_REC_COMMAND = re.compile(r'(`|\$\()\s*(.*)\s*([`)])$')
60-
PLATFORM_REC_COMMAND = re.compile(r'(\$\()\s*(.*)\s*([)])$')
60+
PLATFORM_REC_COMMAND = re.compile(r'(\$\()\s*(.*)\s*(\))')
6161

6262
HOST_SELECTION_METHODS = {
6363
'definition order': lambda goodhosts: goodhosts[0],

cylc/flow/task_events_mgr.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ def _get_remote_conf(self, itask, key):
548548
itask.platform[key]
549549
)
550550

551-
def _get_workflow_platforms_conf(self, itask, key):
551+
def _get_workflow_platforms_conf(self, itask: 'TaskProxy', key: str):
552552
"""Return top level [runtime] items that default to platforms."""
553553
overrides = self.broadcast_mgr.get_broadcast(itask.tokens)
554554
return (
@@ -1844,7 +1844,7 @@ def _get_handler_template_variables(
18441844
}
18451845
# fmt: on
18461846

1847-
def _reset_job_timers(self, itask):
1847+
def _reset_job_timers(self, itask: 'TaskProxy'):
18481848
"""Set up poll timer and timeout for task."""
18491849

18501850
if itask.transient:
@@ -1898,18 +1898,18 @@ def _reset_job_timers(self, itask):
18981898
itask.poll_timer = TaskActionTimer(ctx=ctx, delays=delays)
18991899
# Log timeout and polling schedule
19001900
message = f"health: {timeout_key}={timeout_str}"
1901-
# Attempt to group identical consecutive delays as N*DELAY,...
19021901
if itask.poll_timer.delays:
1903-
items = [] # [(number of item - 1, item), ...]
1902+
# Group identical consecutive delays as N*DELAY,...
1903+
items: List[List[float]] = [] # [[number of item, item], ...]
19041904
for delay in itask.poll_timer.delays:
19051905
if items and items[-1][1] == delay:
19061906
items[-1][0] += 1
19071907
else:
1908-
items.append([0, delay])
1908+
items.append([1, delay])
19091909
message += ', polling intervals='
19101910
for num, item in items:
1911-
if num:
1912-
message += '%d*' % (num + 1)
1911+
if num > 1:
1912+
message += f'{num}*'
19131913
message += '%s,' % intvl_as_str(item)
19141914
message += '...'
19151915
LOG.debug(f"[{itask}] {message}")
@@ -1920,7 +1920,7 @@ def _reset_job_timers(self, itask):
19201920
def process_execution_polling_intervals(
19211921
polling_intervals: List[float],
19221922
time_limit: float,
1923-
time_limit_polling_intervals: List[float]
1923+
time_limit_polling_intervals: Optional[List[float]]
19241924
) -> List[float]:
19251925
"""Create a list of polling times.
19261926
@@ -1952,6 +1952,11 @@ def process_execution_polling_intervals(
19521952
>>> this([], 10, [5])
19531953
[15, 5]
19541954
1955+
# There are no execution time limit polling intervals set - just
1956+
# repeat the execution polling interval until the time limit:
1957+
>>> this([10], 25, None)
1958+
[10, 10]
1959+
19551960
# We have a list of execution time limit polling intervals,
19561961
>>> this([10], 25, [5, 6, 7, 8])
19571962
[10, 10, 10, 6, 7, 8]
@@ -1968,17 +1973,19 @@ def process_execution_polling_intervals(
19681973
size = int((time_limit - sum(delays)) / delays[-1])
19691974
delays.extend([delays[-1]] * size)
19701975

1971-
# After the last delay before the execution time limit add the
1972-
# delay to get to the execution_time_limit
1973-
if len(time_limit_polling_intervals) == 1:
1974-
time_limit_polling_intervals.append(
1975-
time_limit_polling_intervals[0]
1976-
)
1977-
time_limit_polling_intervals[0] += time_limit - sum(delays)
1976+
if time_limit_polling_intervals:
1977+
# After the last delay before the execution time limit add the
1978+
# delay to get to the execution_time_limit
1979+
if len(time_limit_polling_intervals) == 1:
1980+
time_limit_polling_intervals.append(
1981+
time_limit_polling_intervals[0]
1982+
)
1983+
time_limit_polling_intervals[0] += time_limit - sum(delays)
1984+
1985+
# After the execution time limit, poll at the
1986+
# execution time limit polling intervals.
1987+
delays += time_limit_polling_intervals
19781988

1979-
# After the execution time limit poll at execution time limit polling
1980-
# intervals.
1981-
delays += time_limit_polling_intervals
19821989
return delays
19831990

19841991
def add_event_timer(self, id_key: EventKey, event_timer) -> None:

cylc/flow/task_remote_mgr.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,18 @@ def _subshell_eval(
143143
return 'localhost'
144144

145145
# Host selection command: $(command) or `command`
146-
match = command_pattern.match(eval_str)
146+
match = command_pattern.search(eval_str)
147147
if match:
148-
cmd_str = match.groups()[1]
148+
cmd_str = match.group(2)
149149
if cmd_str in self.remote_command_map:
150150
# Command recently launched
151151
value = self.remote_command_map[cmd_str]
152152
if isinstance(value, PlatformError):
153153
raise value # command failed
154154
if value is None:
155155
return None # command not yet ready
156-
eval_str = value # command succeeded
156+
# command succeeded
157+
eval_str = eval_str.replace(match.group(0), value)
157158
else:
158159
# Command not launched (or already reset)
159160
self.proc_pool.put_command(

tests/functional/job-submission/19-platform_select.t

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#-------------------------------------------------------------------------------
1818
# Test recovery of a failed host select command for a group of tasks.
1919
. "$(dirname "$0")/test_header"
20-
set_test_number 6
20+
set_test_number 7
2121

2222
install_workflow "${TEST_NAME_BASE}"
2323

@@ -29,20 +29,24 @@ logfile="${WORKFLOW_RUN_DIR}/log/scheduler/log"
2929

3030
# Check that host = $(cmd) is correctly evaluated
3131
grep_ok \
32-
"1/host_subshell.* evaluated as improbable host name$" \
32+
"1/host_subshell/01:.* evaluated as improbable host name$" \
3333
"${logfile}"
3434
grep_ok \
35-
"1/localhost_subshell.* evaluated as localhost$" \
35+
"1/localhost_subshell/01:.* evaluated as localhost$" \
3636
"${logfile}"
3737

3838
# Check that host = `cmd` is correctly evaluated
3939
grep_ok \
40-
"1/host_subshell_backticks.* evaluated as improbable host name$" \
40+
"1/host_subshell_backticks/01:.* evaluated as improbable host name$" \
4141
"${logfile}"
4242

4343
# Check that platform = $(cmd) correctly evaluated
4444
grep_ok \
45-
"1/platform_subshell.* evaluated as improbable platform name$" \
45+
"1/platform_subshell:.* evaluated as improbable platform name$" \
46+
"${logfile}"
47+
48+
grep_ok \
49+
"1/platform_subshell_suffix:.* evaluated as prefix-middle-suffix$" \
4650
"${logfile}"
4751

4852
purge

tests/functional/job-submission/19-platform_select/flow.cylc

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ purpose = """
1515
R1 = """
1616
host_no_subshell
1717
localhost_subshell
18-
platform_subshell:submit-fail? => fin_platform
19-
platform_no_subshell:submit-fail? => fin_platform
20-
host_subshell:submit-fail? => fin_host
21-
host_subshell_backticks:submit-fail? => fin_host
18+
platform_subshell:submit-fail?
19+
platform_no_subshell:submit-fail?
20+
platform_subshell_suffix:submit-fail?
21+
host_subshell:submit-fail?
22+
host_subshell_backticks:submit-fail?
2223
"""
2324

2425
[runtime]
@@ -35,6 +36,9 @@ purpose = """
3536
[[platform_subshell]]
3637
platform = $(echo "improbable platform name")
3738

39+
[[platform_subshell_suffix]]
40+
platform = prefix-$( echo middle )-suffix
41+
3842
[[host_subshell]]
3943
[[[remote]]]
4044
host = $(echo "improbable host name")
@@ -46,9 +50,3 @@ purpose = """
4650
[[localhost_subshell]]
4751
[[[remote]]]
4852
host = $(echo "localhost4.localdomain4")
49-
50-
[[fin_platform]]
51-
script = cylc remove "${CYLC_WORKFLOW_ID}//1/platform_*"
52-
53-
[[fin_host]]
54-
script = cylc remove "${CYLC_WORKFLOW_ID}//1/host_subshell*"

tests/functional/job-submission/19-platform_select/reference.log

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@
44
1/host_subshell -triggered off [] in flow 1
55
1/host_subshell_backticks -triggered off [] in flow 1
66
1/localhost_subshell -triggered off [] in flow 1
7-
1/fin_platform -triggered off ['1/platform_no_subshell', '1/platform_subshell'] in flow 1
8-
1/fin_host -triggered off ['1/host_subshell', '1/host_subshell_backticks'] in flow 1
7+
1/platform_subshell_suffix -triggered off [] in flow 1

0 commit comments

Comments
 (0)