-
Notifications
You must be signed in to change notification settings - Fork 94
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 reg tweak. #2816
Cylc reg tweak. #2816
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried master
branch first.
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ cylc reg BRUNO ./etc/examples/tutorial/cycling/two/
REGISTERED BRUNO -> /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/two
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ ls -la ~/cylc-run/BRUNO/.service/
total 12
drwxrwxr-x 2 kinow kinow 4096 Oct 25 14:09 .
drwxrwxr-x 3 kinow kinow 4096 Oct 25 14:09 ..
lrwxrwxrwx 1 kinow kinow 79 Oct 25 14:09 source -> /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/two
# now re-register without passing the location
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ cylc reg BRUNO
REGISTERED BRUNO -> /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/two
# it said it registered, but actually there were no changes...
Which was indeed weird. Then tried the change in this pull request.
# Better error handling here, as this is not a suite.rc folder
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ cylc reg BRUNO
ERROR: no suite.rc in /home/kinow/Development/python/workspace/cylc
# and prevents registering the same name with a different location by accident
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ cylc reg BRUNO ./etc/examples/tutorial/cycling/five/
ERROR: the name 'BRUNO' already points to /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/two.
Use --redirect to re-use an existing name and run directory.
# of course same name and location is OK
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ cylc reg BRUNO ./etc/examples/tutorial/cycling/two/
REGISTERED BRUNO -> /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/two
# and clever enough to recognize relative paths! Ha!
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ cylc reg BRUNO ./etc/examples/tutorial/cycling/two/../five
ERROR: the name 'BRUNO' already points to /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/two.
Use --redirect to re-use an existing name and run directory.
# redirect works OK too
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ cylc reg BRUNO ./etc/examples/tutorial/cycling/five --redirect
WARNING: the name 'BRUNO' points to /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/two.
It will now be redirected to /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/five.
Files in the existing BRUNO run directory will be overwritten.
REGISTERED BRUNO -> /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/five
kinow@kinow-VirtualBox:~/Development/python/workspace/cylc$ ls -lah ~/cylc-run/BRUNO/.service/
total 12K
drwxrwxr-x 2 kinow kinow 4.0K Oct 25 14:12 .
drwxrwxr-x 3 kinow kinow 4.0K Oct 25 14:09 ..
lrwxrwxrwx 1 kinow kinow 80 Oct 25 14:12 source -> /home/kinow/Development/python/workspace/cylc/etc/examples/tutorial/cycling/five
Change looks good, found no issues in manual tests. Reviewing the code also found nothing out of ordinary.
👍 👏 LGTM
(Updated description above to be clearer). |
(BTW our implicit registration behaviour is doing my head in because the semantics have to be subtly different for |
See also #2818. |
Two approvals, all tests pass ... merging. |
Follow-up to #2759 (sorry) to disallow a confusing edge case.
On master,
cylc reg NAME
(i.e. PATH arg omitted) does nothing if NAME is already registered to another suite, but it registers a suite in$PWD
as NAME [if it isn't already registered].The former case is not correct. If deriving suite path or name from current directory path, it doesn't make sense to simply "re-register" an existing suite in a different location.
So now, on this branch
cylc reg NAME
always "tries to" point NAME at$PWD/suite.rc
. By "tries to" I mean does so if NAME is not already used, otherwise abort unless--redirect
is used (because overwriting an existing run directory is potentially dangerous). This is consistent withcylc reg NAME PATH
always trying to register$PWD/suite.rc
as NAME.In fixing this I tweaked the registration function logic again, to make it easier to follow.