From 03961bcdcd0336a7a216adba7016879d52913a14 Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Fri, 6 May 2022 23:18:23 +1200 Subject: [PATCH 1/5] Allow workflow source dir under cylc-run. --- cylc/flow/workflow_files.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cylc/flow/workflow_files.py b/cylc/flow/workflow_files.py index ab271d2b378..e389781b65b 100644 --- a/cylc/flow/workflow_files.py +++ b/cylc/flow/workflow_files.py @@ -1791,7 +1791,6 @@ def validate_source_dir( """Ensure the source directory is valid: - has flow file - does not contain reserved dir names - - is not inside ~/cylc-run. Args: source: Path to source directory @@ -1799,7 +1798,6 @@ def validate_source_dir( WorkflowFilesError: If log, share, work or _cylc-install directories exist in the source directory. - Cylc installing from within the cylc-run dir """ # Ensure source dir does not contain log, share, work, _cylc-install for dir_ in WorkflowFiles.RESERVED_DIRNAMES: @@ -1809,14 +1807,6 @@ def validate_source_dir( f"- {dir_} exists in source directory." ) cylc_run_dir = get_cylc_run_dir() - if is_relative_to( - os.path.abspath(os.path.realpath(source)), - os.path.abspath(os.path.realpath(cylc_run_dir)) - ): - raise WorkflowFilesError( - f"{workflow_name} installation failed. Source directory " - f"should not be in {cylc_run_dir}." - ) check_flow_file(source) From 7aa486f7657e86dedc5d68c54804c285028652e6 Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Fri, 6 May 2022 23:48:57 +1200 Subject: [PATCH 2/5] Fix tests. --- tests/functional/cylc-install/02-failures.t | 19 +------------------ tests/unit/test_workflow_files.py | 6 ------ 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/tests/functional/cylc-install/02-failures.t b/tests/functional/cylc-install/02-failures.t index fe30891fcc8..b752bdd7e1c 100644 --- a/tests/functional/cylc-install/02-failures.t +++ b/tests/functional/cylc-install/02-failures.t @@ -20,7 +20,7 @@ . "$(dirname "$0")/test_header" -set_test_number 47 +set_test_number 45 create_test_global_config '' ' [install] @@ -228,23 +228,6 @@ grep_ok "WorkflowFilesError: Symlink broken" "${TEST_NAME}.stderr" rm -rf "${ALT_SOURCE}" purge_rnd_workflow -# ----------------------------------------------------------------------------- -# Test cylc install can not be run from within the cylc-run directory - -make_rnd_workflow -TEST_NAME="${TEST_NAME_BASE}-forbid-cylc-run-dir-install" -BASE_NAME="test-install-${CYLC_TEST_TIME_INIT}" -mkdir -p "${RUN_DIR}/${BASE_NAME}/${TEST_SOURCE_DIR_BASE}/${TEST_NAME}" && cd "$_" || exit -touch flow.cylc -run_fail "${TEST_NAME}" cylc install --workflow-name "$RND_WORKFLOW_NAME" -contains_ok "${TEST_NAME}.stderr" <<__ERR__ -WorkflowFilesError: ${RND_WORKFLOW_NAME} installation failed. Source directory should not be in ${RUN_DIR}. -__ERR__ - -cd "${RUN_DIR}" || exit -rm -rf "${BASE_NAME}" -purge_rnd_workflow - # ----------------------------------------------------------------------------- # --run-name cannot be a path diff --git a/tests/unit/test_workflow_files.py b/tests/unit/test_workflow_files.py index cae7cb91764..d2ba2991b62 100644 --- a/tests/unit/test_workflow_files.py +++ b/tests/unit/test_workflow_files.py @@ -1884,12 +1884,6 @@ def test_validate_source_dir(tmp_run_dir: Callable, tmp_src_dir: Callable): with pytest.raises(WorkflowFilesError) as exc_info: validate_source_dir(src_dir, 'roland') assert "exists in source directory" in str(exc_info.value) - # Test that src dir is not allowed to be inside ~/cylc-run - src_dir = cylc_run_dir / 'dieter' - src_dir.mkdir() - with pytest.raises(WorkflowFilesError) as exc_info: - validate_source_dir(src_dir, 'dieter') - assert "Source directory should not be in" in str(exc_info.value) @pytest.mark.parametrize( From 24ede3ed7ca1337b7ad8c5332a557845db100733 Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Fri, 6 May 2022 23:53:29 +1200 Subject: [PATCH 3/5] Update change log. --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index caf3930eef4..168fc477fac 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -35,9 +35,13 @@ Third Release Candidate for Cylc 8 suitable for acceptance testing. ### Enhancements + [#4842](https://github.com/cylc/cylc-flow/pull/4842) - Improve Jinja2 error reporting when the error is behind an `{% include`. +[#4861](https://github.com/cylc/cylc-flow/pull/4861) - Allow workflow source + directories to be under `cylc-run`. + [#4828](https://github.com/cylc/cylc-flow/pull/4828) - scan CLI: corrupt workflow contact files should result in a warning, not a crash. From fefc63471634df01b179defe83c25313140915a3 Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Sat, 7 May 2022 00:01:20 +1200 Subject: [PATCH 4/5] flake8 fixes --- cylc/flow/workflow_files.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/cylc/flow/workflow_files.py b/cylc/flow/workflow_files.py index e389781b65b..3a77e035532 100644 --- a/cylc/flow/workflow_files.py +++ b/cylc/flow/workflow_files.py @@ -54,7 +54,6 @@ expand_path, get_cylc_run_dir, get_workflow_run_dir, - is_relative_to, make_localhost_symlinks, parse_rm_dirs, remove_dir_and_target, @@ -1806,7 +1805,6 @@ def validate_source_dir( f"{workflow_name} installation failed. " f"- {dir_} exists in source directory." ) - cylc_run_dir = get_cylc_run_dir() check_flow_file(source) From 55b0f54e70e8554da9d0e6b56321ec3f03dcaddc Mon Sep 17 00:00:00 2001 From: Hilary James Oliver Date: Fri, 13 May 2022 17:00:57 +1200 Subject: [PATCH 5/5] Add unit tests. --- tests/unit/test_workflow_files.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/unit/test_workflow_files.py b/tests/unit/test_workflow_files.py index d2ba2991b62..83d2b586da0 100644 --- a/tests/unit/test_workflow_files.py +++ b/tests/unit/test_workflow_files.py @@ -1884,6 +1884,19 @@ def test_validate_source_dir(tmp_run_dir: Callable, tmp_src_dir: Callable): with pytest.raises(WorkflowFilesError) as exc_info: validate_source_dir(src_dir, 'roland') assert "exists in source directory" in str(exc_info.value) + # Test that src dir is allowed to be inside ~/cylc-run + src_dir = cylc_run_dir / 'dieter' + src_dir.mkdir() + (src_dir / WorkflowFiles.FLOW_FILE).touch() + validate_source_dir(src_dir, 'dieter') + # Test that src dir is not allowed to be an installed dir. + src_dir = cylc_run_dir / 'ajay' + src_dir.mkdir() + (src_dir / WorkflowFiles.Install.DIRNAME).mkdir() + (src_dir / WorkflowFiles.FLOW_FILE).touch() + with pytest.raises(WorkflowFilesError) as exc_info: + validate_source_dir(src_dir, 'ajay') + assert "exists in source directory" in str(exc_info.value) @pytest.mark.parametrize(