Skip to content

Commit

Permalink
Fcm make fix for remote and subshell platforms (#2557)
Browse files Browse the repository at this point in the history
task-run: fcm make Cylc fixes

- Support single stage make on remote Cylc platforms (where the workflow config is not present).
- Handle hosts/platforms configured as subshells.
  • Loading branch information
datamel authored Mar 22, 2022
1 parent d9e0cd9 commit 38c08a0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ passes through `$CYLC_ENV_NAME` and the user's login env vars.

### Fixes

[#2557](https://github.com/metomi/rose/pull/2557) -
[FCM Make](https://github.com/metomi/fcm) now works
correctly with remote tasks and tasks which have their platform or host defined
as a subshell.

[#2548](https://github.com/metomi/rose/pull/2548) - Added back the
`rose-conf.vim` syntax highlighting file for ViM that was accidentally removed.

Expand Down
14 changes: 10 additions & 4 deletions metomi/rose/apps/fcm_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# ----------------------------------------------------------------------------
"""Builtin application: run "fcm make"."""

from contextlib import suppress
import os
from pipes import quote
import shlex
Expand All @@ -29,7 +30,10 @@
env_var_process,
)
from metomi.rose.fs_util import FileSystemEvent
from metomi.rose.popen import RosePopenError
from metomi.rose.popen import (
RosePopenError,
WorkflowFileNotFoundError
)

ORIG = 0
CONT = 1
Expand Down Expand Up @@ -209,9 +213,11 @@ def _run_orig(
task_name_cont = task.task_name.replace(
orig_cont_map[ORIG], orig_cont_map[CONT]
)
auth = app_runner.suite_engine_proc.get_task_auth(
task.suite_name, task_name_cont
)
auth = None
with suppress(WorkflowFileNotFoundError):
auth = app_runner.suite_engine_proc.get_task_auth(
task.suite_name, task_name_cont
)
if auth is not None:
dest_cont = _conf_value(conf_tree, ["dest-cont"])
if dest_cont is None:
Expand Down
12 changes: 12 additions & 0 deletions metomi/rose/popen.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,18 @@
from metomi.rose.resource import ResourceLocator


class WorkflowFileNotFoundError(Exception):

"""Error: Workflow file not found.
Expected error for fcm_make remote where the flow.cylc is
not included in the file installation.
"""

def __str__(self):
return "No workflow file found."


class RosePopenError(Exception):

"""An error raised when a shell command call fails."""
Expand Down
11 changes: 7 additions & 4 deletions metomi/rose/suite_engine_procs/cylc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from uuid import uuid4

from metomi.rose.fs_util import FileSystemEvent
from metomi.rose.popen import RosePopenError
from metomi.rose.popen import WorkflowFileNotFoundError, RosePopenError
from metomi.rose.reporter import Reporter
from metomi.rose.suite_engine_proc import (
SuiteEngineProcessor,
Expand Down Expand Up @@ -104,16 +104,19 @@ def get_task_auth(
"""
# n.b. Imports inside function to avoid dependency on Cylc and
# Cylc-Rose is Rose is being used with a different workflow engine.
from cylc.flow.platforms import get_host_from_platform
from cylc.flow.exceptions import WorkflowFilesError
from cylc.flow.hostuserutil import is_remote_platform
from cylc.flow.platforms import get_host_from_platform
from cylc.rose.platform_utils import get_platform_from_task_def

# Check whether task has been defined.
try:
platform = get_platform_from_task_def(suite_name, task_name)
except KeyError:
return None
except (WorkflowFilesError):
raise WorkflowFileNotFoundError
else:
if platform is None:
return 'localhost'
# If task has been defined return host:
if is_remote_platform(platform):
return get_host_from_platform(platform)
Expand Down
2 changes: 1 addition & 1 deletion t/rose-task-run/08-app-fcm-make.t
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ if [[ -n $JOB_HOST ]]; then
file_cmp "$TEST_KEY" "$TEST_KEY" <<'__DB__'
fcm_make2_t5|succeeded
fcm_make_t1|succeeded
fcm_make_t1_remote|succeeded
fcm_make_t2|succeeded
fcm_make_t3|succeeded
fcm_make_t4|succeeded
Expand Down Expand Up @@ -111,7 +112,6 @@ else

TEST_KEY="$TEST_KEY_BASE-t5-part-2"
# TODO: this test relies on "retrieve job logs = True".
#rose suite-log -q --name=$FLOW --update fcm_make2_t5
file_grep "$TEST_KEY.out" \
"\\[INFO\\] [0-9]*-[0-9]*-[0-9]*T[0-9]*:[0-9]*:[0-9]*+[0:9]* fcm make -C .*/cylc-run/${FLOW}/share/fcm_make_t5 -n 2 -j 4" \
$FLOW_RUN_DIR/log/job/1/fcm_make2_t5/01/job.out
Expand Down
8 changes: 7 additions & 1 deletion t/rose-task-run/08-app-fcm-make/flow.cylc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fcm_make_t3 # opt.jobs
fcm_make_t4 # args
{% if HOST is defined %}
fcm_make_t5 => fcm_make2_t5 # mirror
fcm_make_t1_remote # basic remote
{% endif %}
"""
[runtime]
Expand All @@ -23,6 +24,11 @@ fcm_make_t5 => fcm_make2_t5 # mirror
[[fcm_make_t5]]
[[fcm_make2_t5]]
[[[remote]]]
host={{HOST}}
host=$(echo {{HOST}})
retrieve job logs = true
[[fcm_make_t1_remote]]
[[[environment]]]
ROSE_TASK_APP = fcm_make_t1
[[[remote]]]
host=$(echo {{HOST}})
{% endif %}

0 comments on commit 38c08a0

Please sign in to comment.