From 0e34b6da7f064fb05377a37c71e1d7f45efaa830 Mon Sep 17 00:00:00 2001 From: Tim Pillinger <26465611+wxtim@users.noreply.github.com> Date: Fri, 31 May 2024 10:14:54 +0100 Subject: [PATCH] Add CYLC_SHARE_CYCLE_DIR to task script. test fix --- changes.d/6117.feat.md | 1 + cylc/flow/etc/job.sh | 2 ++ tests/functional/cylc-clean/01-remote.t | 1 + .../jobscript/02-share-cycle-cycle.t | 31 +++++++++++++++++++ .../jobscript/02-share-cycle-cycle/flow.cylc | 11 +++++++ 5 files changed, 46 insertions(+) create mode 100644 changes.d/6117.feat.md mode change 100644 => 100755 cylc/flow/etc/job.sh create mode 100644 tests/functional/jobscript/02-share-cycle-cycle.t create mode 100644 tests/functional/jobscript/02-share-cycle-cycle/flow.cylc diff --git a/changes.d/6117.feat.md b/changes.d/6117.feat.md new file mode 100644 index 00000000000..f7affba4337 --- /dev/null +++ b/changes.d/6117.feat.md @@ -0,0 +1 @@ +Make workflow/share/cycle/ available as CYLC_SHARE_CYCLE_DIR \ No newline at end of file diff --git a/cylc/flow/etc/job.sh b/cylc/flow/etc/job.sh old mode 100644 new mode 100755 index 1a20a88071f..110fdc0d24c --- a/cylc/flow/etc/job.sh +++ b/cylc/flow/etc/job.sh @@ -95,6 +95,7 @@ cylc__job__main() { CYLC_TASK_WORK_DIR_BASE="${CYLC_TASK_CYCLE_POINT}/${CYLC_TASK_NAME}" fi export CYLC_TASK_WORK_DIR="${CYLC_WORKFLOW_WORK_DIR}/${CYLC_TASK_WORK_DIR_BASE}" + export CYLC_SHARE_CYCLE_DIR="${CYLC_WORKFLOW_SHARE_DIR}/cycle/${CYLC_TASK_CYCLE_POINT}" typeset contact="${CYLC_WORKFLOW_RUN_DIR}/.service/contact" if [[ -f "${contact}" ]]; then # (contact file not present for polled platforms) @@ -135,6 +136,7 @@ cylc__job__main() { export PYTHONPATH="${CYLC_WORKFLOW_RUN_DIR}/share/lib/python:${CYLC_WORKFLOW_RUN_DIR}/lib/python:${PYTHONPATH:-}" # Create share and work directories mkdir -p "${CYLC_WORKFLOW_SHARE_DIR}" || true + mkdir -p "${CYLC_SHARE_CYCLE_DIR}" || true mkdir -p "$(dirname "${CYLC_TASK_WORK_DIR}")" || true mkdir -p "${CYLC_TASK_WORK_DIR}" cd "${CYLC_TASK_WORK_DIR}" diff --git a/tests/functional/cylc-clean/01-remote.t b/tests/functional/cylc-clean/01-remote.t index 67148478eb0..451656b9773 100644 --- a/tests/functional/cylc-clean/01-remote.t +++ b/tests/functional/cylc-clean/01-remote.t @@ -80,6 +80,7 @@ ${TEST_DIR}/${SYM_NAME}/cycle/cylc-run/${CYLC_TEST_REG_BASE} | \`-- ${TEST_NAME_BASE} | \`-- share | \`-- cycle +| \`-- 1 \`-- leave-me-alone ${TEST_DIR}/${SYM_NAME}/other/cylc-run/${CYLC_TEST_REG_BASE} \`-- ${FUNCTIONAL_DIR} diff --git a/tests/functional/jobscript/02-share-cycle-cycle.t b/tests/functional/jobscript/02-share-cycle-cycle.t new file mode 100644 index 00000000000..f41b5f6662d --- /dev/null +++ b/tests/functional/jobscript/02-share-cycle-cycle.t @@ -0,0 +1,31 @@ +#!/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 . + +# Assert that workflow/share/cycle/ is created and exported. + +. "$(dirname "$0")/test_header" +set_test_number 4 + +# Setup: +install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" +run_ok "${TEST_NAME_BASE}.validate" cylc validate "${WORKFLOW_NAME}" +workflow_run_ok "${TEST_NAME_BASE}.play" cylc play --no-detach "${WORKFLOW_NAME}" + +grep_ok "Hello World" "${WORKFLOW_RUN_DIR}/share/cycle/19900211T0000Z/stuff" +grep_ok "Hello World" "${WORKFLOW_RUN_DIR}/share/cycle/19900212T0000Z/stuff" + +purge diff --git a/tests/functional/jobscript/02-share-cycle-cycle/flow.cylc b/tests/functional/jobscript/02-share-cycle-cycle/flow.cylc new file mode 100644 index 00000000000..b8d08fe942f --- /dev/null +++ b/tests/functional/jobscript/02-share-cycle-cycle/flow.cylc @@ -0,0 +1,11 @@ +[scheduling] + initial cycle point = 19900211 + final cycle point = 19900212 + [[graph]] + P1D = task + +[runtime] + [[task]] + script = """ + echo "Hello World" > "${CYLC_SHARE_CYCLE_DIR}/stuff" + """ \ No newline at end of file