Skip to content
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

Cylc install #4000

Merged
merged 13 commits into from
Jan 31, 2021
Merged

Cylc install #4000

merged 13 commits into from
Jan 31, 2021

Conversation

datamel
Copy link
Contributor

@datamel datamel commented Dec 16, 2020

Cylc Install command added. These changes close #3889

Cylc can now install workflows from from arbitrary locations into the cylc-run directory.

This PR includes:

  • Removing cylc register command.
  • New install log added in log directory: log/install/<timestamp>-install.log

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Appropriate tests are included (unit and/or functional).
  • Appropriate change log entry included. - TODO before ready for review
  • (master branch) I have opened a documentation PR at cylc/cylc-doc/pull/XXXX. _TODO
  • No dependency changes.

@datamel datamel self-assigned this Dec 16, 2020
@hjoliver
Copy link
Member

Looks impressive @datamel 🎉

@oliver-sanders
Copy link
Member

Dammit I totally forgot we were approaching PR 4000!

@wxtim
Copy link
Member

wxtim commented Dec 17, 2020

Dammit I totally forgot we were approaching PR 4000!

IMO this is why Mel waited for a few days to put up the draft PR!

cylc/flow/pathutil.py Outdated Show resolved Hide resolved
@oliver-sanders oliver-sanders mentioned this pull request Dec 17, 2020
4 tasks
@oliver-sanders
Copy link
Member

oliver-sanders commented Dec 29, 2020

The bash docker test failures are nothing to worry about, those tests pass locally, likely that the test configuration requires a bit of a poke.

Looking at the GH actions cylc-run directory it looks like the flow.cylc files are not in place suggesting that that installation failed somehow. Perhaps there is some useful error that is being swallowed by 2>/dev/null?

--- a/tests/functional/lib/bash/test_header
+++ b/tests/functional/lib/bash/test_header
@@ -430,7 +430,7 @@ install_suite() {
     SUITE_RUN_DIR="${RUN_DIR}/${SUITE_NAME}"
     mkdir -p "${TEST_DIR}/${SUITE_NAME}/" # make source dir
     cp -r "${TEST_SOURCE_DIR}/${TEST_SOURCE_BASE}/"* "${TEST_DIR}/${SUITE_NAME}/"
-    cylc install --no-run-name --flow-name="${SUITE_NAME}" --directory="${TEST_DIR}/${SUITE_NAME}" 2>'/dev/null'
+    cylc install --no-run-name --flow-name="${SUITE_NAME}" --directory="${TEST_DIR}/${SUITE_NAME}"
     cd "${TEST_DIR}/${SUITE_NAME}/"
 }

It is possible that is might be installing the files in the wrong place? We run as root inside the docker images.

@oliver-sanders
Copy link
Member

The cylc-rose stuff has been merged now, should be straight forward to merge the two cylc install commands, just need to ensure the plugins get called at the right point.

pre_configure - Before the flow configuration is read.
post_install - Last thing that cylc install does.

@oliver-sanders
Copy link
Member

oliver-sanders commented Dec 30, 2020

Took a crack, this seems to do the job:

diff --git a/cylc/flow/scripts/install.py b/cylc/flow/scripts/install.py
index 5011996d2..f773ffdc4 100755
--- a/cylc/flow/scripts/install.py
+++ b/cylc/flow/scripts/install.py
@@ -58,9 +58,13 @@ multiple workflow run directories that link to the same suite definition.
 
 """
 
+import os
+import pkg_resources
+
 from cylc.flow.option_parsers import CylcOptionParser as COP
-from cylc.flow.suite_files import install_workflow
 from cylc.flow.terminal import cli_function
+from cylc.flow.pathutil import get_workflow_run_dir
+from cylc.flow.suite_files import install_workflow
 
 
 def get_option_parser():
@@ -116,14 +120,30 @@ def get_option_parser():
 def main(parser, opts, flow_name=None, src=None):
     if opts.no_run_name and opts.run_name:
         parser.error(
-            """options --no-run-name and --run-name are mutually exclusive.
+            """opts --no-run-name and --run-name are mutually exclusive.
             Use one or the other""")
-    install_workflow(
+
+    for entry_point in pkg_resources.iter_entry_points(
+        'cylc.pre_configure'
+    ):
+        entry_point.resolve()(opts.source)
+
+    flow_name = install_workflow(
         flow_name=opts.flow_name,
         source=opts.source,
         run_name=opts.run_name,
         no_run_name=opts.no_run_name,
-        no_symlinks=opts.no_symlinks)
+        no_symlinks=opts.no_symlinks
+    )
+
+    for entry_point in pkg_resources.iter_entry_points(
+        'cylc.post_install'
+    ):
+        entry_point.resolve()(
+            dir_=opts.source or os.getcwd(),  # move the source dir logic into this script
+            opts=opts,
+            dest_root=get_workflow_run_dir(flow_name)
+        )
 
 
 if __name__ == "__main__":

@datamel datamel force-pushed the cylc-install branch 4 times, most recently from b3be897 to b66a765 Compare January 6, 2021 10:39
@oliver-sanders
Copy link
Member

This might be the answer to the bash test failures:

diff --git a/dockerfiles/bash/Dockerfile b/dockerfiles/bash/Dockerfile
index 8b9f6a2e1..2396924a1 100644
--- a/dockerfiles/bash/Dockerfile
+++ b/dockerfiles/bash/Dockerfile
@@ -13,6 +13,7 @@ RUN apt-get update && apt-get install -y \
     python3.7-dev \
     sqlite3 \
     wget \
+    rsync \
     && python3.7 -m pip install -U pip setuptools \
     && rm -rf /var/lib/apt/lists/*

@datamel datamel marked this pull request as ready for review January 6, 2021 13:46
cylc/flow/suite_files.py Show resolved Hide resolved
cylc/flow/suite_files.py Outdated Show resolved Hide resolved
cylc/flow/suite_files.py Outdated Show resolved Hide resolved
cylc/flow/suite_files.py Show resolved Hide resolved
cylc/flow/suite_files.py Show resolved Hide resolved
cylc/flow/suite_files.py Outdated Show resolved Hide resolved
return rsync_cmd


def install_workflow(flow_name=None, source=None, run_name=None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can break this function down a bit, would make it possible to unit test bits of of (e.g. the runN bit).

@oliver-sanders
Copy link
Member

Something seems to have angered the tests there. Lots of this diff in the logs:

-Parsing cylctb-20210112T182706Z/f/cylc-diff/00-basic-2 (/tmp/tmp.yw9DTu8vUR/cylctb-20210112T182706Z/f/cylc-diff/00-basic-2/flow.cylc)
250
+Parsing cylctb-20210112T182706Z/f/cylc-diff/00-basic-1 (/home/runner/cylc-run/cylctb-20210112T182706Z/f/cylc-diff/00-basic-1/flow.cylc)

@datamel
Copy link
Contributor Author

datamel commented Jan 13, 2021

Something seems to have angered the tests there. Lots of this diff in the logs:

-Parsing cylctb-20210112T182706Z/f/cylc-diff/00-basic-2 (/tmp/tmp.yw9DTu8vUR/cylctb-20210112T182706Z/f/cylc-diff/00-basic-2/flow.cylc)
250
+Parsing cylctb-20210112T182706Z/f/cylc-diff/00-basic-1 (/home/runner/cylc-run/cylctb-20210112T182706Z/f/cylc-diff/00-basic-1/flow.cylc)

Just looking into it now - angering the tests is my speciality!

@oliver-sanders
Copy link
Member

oliver-sanders commented Jan 19, 2021

Looking at the timestamps in the logs none of the four cancelled jobs from the last run produced any output in the minutes before being cancelled.

This suggests that some tests are hanging.

Unfortunately it can be quite hard to work out which of the tests are hanging (I have an idea on this I developed for the Rose tests, will try some time) but you can always try locally.

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given a test locally, works well.

I found one quirk where you can end up with a combination of custom and automatically named runs:

$ cylc install --run-name a
$ cylc install
$ tree ~/cylc-run -L 2
~/cylc-run/
└── testy
    ├── _cylc-install
    ├── b
    ├── run1
    └── runN -> ~/cylc-run/testy/run1

I think the correct behaviour should be that the second install would fail, we can tell that b is an installed flow not a run because ~/cylc-run/testy/b contains a flow.cylc file.

cylc/flow/suite_files.py Outdated Show resolved Hide resolved
@datamel
Copy link
Contributor Author

datamel commented Jan 22, 2021

I think the correct behaviour should be that the second install would fail, we can tell that b is an installed flow not a run because ~/cylc-run/testy/b contains a flow.cylc file.

Are we happy for someone to do a named run after a named run? Is it only mix of named and run numbered installs we want to avoid?

e.g.

$ cylc install --run-name a
$ cylc install --run-name b
$ tree ~/cylc-run/testy -L 1

~/cylc-run/testy
|-- _cylc-install
|-- a
`-- b
 

@oliver-sanders
Copy link
Member

Yes, because the meaning of the runN symlink gets fuzzy.

Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice tests!

GH actions is angry again, looks like all tests are failing for the same reason at least.

tests/functional/cylc-install/00-simple.t Show resolved Hide resolved
Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nearly there!

Screenshot 2021-01-26 at 17 09 25

The argument of cylc install is a little funny with its flow/path/PWD opts thing, but we can sort that with the universal id changes later.

cylc/flow/suite_files.py Outdated Show resolved Hide resolved
cylc/flow/suite_files.py Show resolved Hide resolved
cylc/flow/suite_files.py Outdated Show resolved Hide resolved
datamel and others added 11 commits January 26, 2021 20:59
Cylc install, prohibit source in cylc-run
Add cylc-install to cylc-clean
Add functional tests for cylc-install
Co-authored-by: Oliver Sanders <oliver.sanders@metoffice.gov.uk>
Fix functional test for cylc-install
* abort if no flow is to be purged
* only wait on lsof for a maximum of five tries
Copy link
Member

@oliver-sanders oliver-sanders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, a lot of nuances and Cylc history has been blasted aside here, nice.

There are some minor quirks I think we should skip over for this review and come back to later:

  • The argument of cylc install can be reg/path.
    • Come back to this later (universal id stuff).
  • The flow.cylc is being created in the "source" dir and rsync'ed to the "run" dir.
    • It may be better not to create the symlink in the "source" dir.
    • This will silence future warnings.
    • Users should just mv suite.rc flow.cylc.
  • The runN symlinks are absolute rather than relative.
    • This blocks registration changes, but perhaps that's not the worst thing?

@hjoliver
Copy link
Member

Looks good, a lot of nuances and Cylc history has been blasted aside here, nice.

yeah brilliant, thanks @datamel 🎉 I'll have a close look as soon as possible...

Copy link
Member

@hjoliver hjoliver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, no problems found 🎉 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cylc install
6 participants