-
Notifications
You must be signed in to change notification settings - Fork 96
Fix platform selection from subshell not re-evaluating each time #6836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
oliver-sanders
merged 6 commits into
cylc:8.5.x
from
wxtim:#6808.fix.platform_selection_from_subshell
Aug 18, 2025
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
005c5c0
Prevent evaluated expression being pushed permenantly into
wxtim 2f5e9cb
Tidy test
MetRonnie 98d6b92
Merge pull request #73 from MetRonnie/platform-subshell-2
wxtim 1a69422
Avoid changing the task runtime config object at all.
wxtim 1dc1ba3
response to review
wxtim 7fcb7e7
Merge upstream/8.5.x into pr/wxtim/6836
MetRonnie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fix a bug causing the results of `platform = $(subshell commands)` to be cached, and preventing re-evaluation for each task with the same config. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1236,10 +1236,10 @@ def _prep_submit_task_job( | |
| f"\"{itask.identity}\" the following are not compatible:\n" | ||
| ) | ||
|
|
||
| host_n, platform_name = None, None | ||
| host_name, platform_name = [None] * 2 | ||
| try: | ||
| if rtconfig['remote']['host'] is not None: | ||
| host_n = self.task_remote_mgr.eval_host( | ||
| host_name = self.task_remote_mgr.eval_host( | ||
| rtconfig['remote']['host'] | ||
| ) | ||
| else: | ||
|
|
@@ -1258,31 +1258,34 @@ def _prep_submit_task_job( | |
| return False | ||
| else: | ||
| # host/platform select not ready | ||
| if host_n is None and platform_name is None: | ||
| if host_name is None and platform_name is None: | ||
| return None | ||
| elif ( | ||
| host_n is None | ||
| host_name is None | ||
| and rtconfig['platform'] | ||
| and rtconfig['platform'] != platform_name | ||
| ): | ||
| LOG.debug( | ||
| f"for task {itask.identity}: platform = " | ||
| f"{rtconfig['platform']} evaluated as {platform_name}" | ||
| ) | ||
| rtconfig['platform'] = platform_name | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For reference in #6990 |
||
| # orig_platform_name = rtconfig['platform'] | ||
| # rtconfig['platform'] = platform_name | ||
wxtim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| elif ( | ||
| platform_name is None | ||
| and rtconfig['remote']['host'] != host_n | ||
| and rtconfig['remote']['host'] != host_name | ||
| ): | ||
| LOG.debug( | ||
| f"[{itask}] host = " | ||
| f"{rtconfig['remote']['host']} evaluated as {host_n}" | ||
| f"{rtconfig['remote']['host']} evaluated as {host_name}" | ||
| ) | ||
| rtconfig['remote']['host'] = host_n | ||
|
|
||
| try: | ||
| platform = get_platform( | ||
| rtconfig, itask.tdef.name, bad_hosts=self.bad_hosts | ||
| platform_name or rtconfig, | ||
| itask.tdef.name, | ||
| bad_hosts=self.bad_hosts, | ||
| evaluated_host=host_name, | ||
| ) | ||
| except PlatformLookupError as exc: | ||
| itask.waiting_on_job_prep = False | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env bash | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to write this as an integration test... But couldn't make it play ball. |
||
| # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. | ||
| # Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| #----------------------------------------------------------------------------- | ||
|
|
||
| # If a task has a platform set using a subshell this should be evaluated | ||
| # every time the task is run. | ||
| # https://github.com/cylc/cylc-flow/issues/6808 | ||
| export REQUIRE_PLATFORM='loc:remote' | ||
|
|
||
| . "$(dirname "$0")/test_header" | ||
|
|
||
| set_test_number 3 | ||
|
|
||
| install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" | ||
|
|
||
| workflow_run_ok "${TEST_NAME_BASE}-run" \ | ||
| cylc play "${WORKFLOW_NAME}" --debug --no-detach | ||
|
|
||
| named_grep_ok "1/remote_task submits to ${CYLC_TEST_PLATFORM}" \ | ||
| "\[1/remote_task/01:preparing\] submitted to ${CYLC_TEST_PLATFORM}" \ | ||
| "${WORKFLOW_RUN_DIR}/log/scheduler/log" | ||
|
|
||
| named_grep_ok "2/remote_task submits to localhost" \ | ||
| "\[2/remote_task/01:preparing\] submitted to localhost" \ | ||
| "${WORKFLOW_RUN_DIR}/log/scheduler/log" | ||
|
|
||
| purge | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #!jinja2 | ||
| [scheduler] | ||
| [[events]] | ||
| stall timeout = PT0S | ||
|
|
||
| [scheduling] | ||
| cycling mode = integer | ||
| final cycle point = 2 | ||
| [[graph]] | ||
| P1 = remote_task[-P1] => toggler => remote_task | ||
|
|
||
| [runtime] | ||
| [[remote_task]] | ||
| platform = $(cat ${CYLC_WORKFLOW_RUN_DIR}/pretend-hall-info) | ||
|
|
||
| [[toggler]] | ||
| script = """ | ||
| # Toggle the platform between localhost and the remote host | ||
| # using the content of a file, ${CYLC_WORKFLOW_RUN_DIR}/pretend-hall-info. | ||
| # between localhost and the remote. | ||
|
|
||
| if (( $CYLC_TASK_CYCLE_POINT % 2 == 1 )); then | ||
| echo ${REMOTE_PLATFORM} > ${CYLC_WORKFLOW_RUN_DIR}/pretend-hall-info | ||
| cylc message -- "changing platform to ${REMOTE_PLATFORM}" | ||
| else | ||
| echo "localhost" > ${CYLC_WORKFLOW_RUN_DIR}/pretend-hall-info | ||
| cylc message -- "changing platform to localhost" | ||
| fi | ||
| """ | ||
| [[[environment]]] | ||
| REMOTE_PLATFORM = {{ CYLC_TEST_PLATFORM }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| #!/usr/bin/env bash | ||
| # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. | ||
| # Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
| # | ||
| # This program is free software: you can redistribute it and/or modify | ||
| # it under the terms of the GNU General Public License as published by | ||
| # the Free Software Foundation, either version 3 of the License, or | ||
| # (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| #----------------------------------------------------------------------------- | ||
|
|
||
| # If a task has a platform set using a subshell this should be evaluated | ||
wxtim marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # every time the task is run. | ||
| # https://github.com/cylc/cylc-flow/issues/6808 | ||
| export REQUIRE_PLATFORM='loc:remote' | ||
|
|
||
| . "$(dirname "$0")/test_header" | ||
|
|
||
| set_test_number 3 | ||
|
|
||
| install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" | ||
|
|
||
| workflow_run_ok "${TEST_NAME_BASE}-run" \ | ||
| cylc play "${WORKFLOW_NAME}" --debug --no-detach | ||
|
|
||
| named_grep_ok "1/remote_task submits to ${CYLC_TEST_PLATFORM}" \ | ||
| "\[1/remote_task/01:preparing\] submitted to ${CYLC_TEST_HOST}" \ | ||
| "${WORKFLOW_RUN_DIR}/log/scheduler/log" | ||
|
|
||
| named_grep_ok "2/remote_task submits to localhost" \ | ||
| "\[2/remote_task/01:preparing\] submitted to localhost" \ | ||
| "${WORKFLOW_RUN_DIR}/log/scheduler/log" | ||
|
|
||
| purge | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!jinja2 | ||
| [scheduler] | ||
| [[events]] | ||
| stall timeout = PT0S | ||
|
|
||
| [scheduling] | ||
| cycling mode = integer | ||
| final cycle point = 2 | ||
| [[graph]] | ||
| P1 = remote_task[-P1] => toggler => remote_task | ||
|
|
||
| [runtime] | ||
| [[remote_task]] | ||
| [[[remote]]] | ||
| host = $(cat ${CYLC_WORKFLOW_RUN_DIR}/pretend-hall-info) | ||
|
|
||
| [[toggler]] | ||
| script = """ | ||
| # Toggle the platform between localhost and the remote host | ||
| # using the content of a file, ${CYLC_WORKFLOW_RUN_DIR}/pretend-hall-info. | ||
| # between localhost and the remote. | ||
|
|
||
| if (( $CYLC_TASK_CYCLE_POINT % 2 == 1 )); then | ||
| echo ${REMOTE_HOST} > ${CYLC_WORKFLOW_RUN_DIR}/pretend-hall-info | ||
| cylc message -- "changing platform to ${REMOTE_HOST}" | ||
| else | ||
| echo "localhost" > ${CYLC_WORKFLOW_RUN_DIR}/pretend-hall-info | ||
| cylc message -- "changing platform to localhost" | ||
| fi | ||
| """ | ||
| [[[environment]]] | ||
| REMOTE_HOST = {{ CYLC_TEST_HOST }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.