-
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
Remove the suite.rc flow.cylc symlink #4506
Conversation
@@ -1700,11 +1699,13 @@ def get_run_dir_info( | |||
|
|||
def detect_both_flow_and_suite(path): | |||
"""Detects if both suite.rc and flow.cylc are in directory. | |||
|
|||
Permits flow.cylc to be a symlink. |
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.
Is this desirable?
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.
@oliver-sanders, I believe you said we should not stop users from manually making a symlink.
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.
Shouldn't we check that the symlink points to the right suite.rc, and raise an error if not?
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.
If there is a flow.cylc there it will use that, regardless of if there is a suite.rc file there. Do we want to forbid users from symlinking other places? I can't think of a reason to forbid, I am probably missing something! I think so long as it is a valid workflow (which will be picked up with other checks) then do we really care how they are sourcing the workflow, it is a bit messy but that is the user's choice?
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.
It sounds reasonable to me that users could have a flow.cylc that is a symlink to either its neighbour suite.rc or somewhere else. But if they have a flow.cylc that symlinks to somewhere else and a suite.rc in there, that sounds to me like it should fail in the same way as a normal flow.cylc file and a suite.rc in there.
TLDR:
ok_but_a_bit_dodgy
`-- flow.cylc -> ~/something.cylc
ok
|-- flow.cylc -> suite.rc # or flow.cylc -> ~/cylc-run/ok/suite.rc?
`-- suite.rc
bad
|-- flow.cylc -> ~/something.cylc
`-- suite.rc
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.
Resolving this as there is a use case (at the MO) for users to source workflow from outside the run directory.
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.
Sorry Mel, not sure if you saw my latest comment above #4506 (comment). I think it is similar to what Oliver said (except he said we don't have to worry about the middle case)
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.
Ah I didn't see that, thanks @MetRonnie, mustn't have refreshed the page before posting.
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.
- Read -looks sensible.
- Played with.
I had one question about the functionality - do we want to allow the symlink to pass?
@@ -1700,11 +1699,13 @@ def get_run_dir_info( | |||
|
|||
def detect_both_flow_and_suite(path): | |||
"""Detects if both suite.rc and flow.cylc are in directory. | |||
|
|||
Permits flow.cylc to be a symlink. |
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.
Shouldn't we check that the symlink points to the right suite.rc, and raise an error if not?
917fd3d
to
b3dca10
Compare
if log_msg: | ||
assert log_msg in caplog.messages | ||
def test_is_forbidden_symlink_returns_false_for_non_symlink(tmp_path): | ||
"""Test sending a non symlink path is not marked as forbidden""" |
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.
Shouldn't a lone symlink also be not marked as forbidden?
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.
Yes, thanks @MetRonnie. Small adjustment and test added. I hope all bases are covered this time!
88ca3aa
to
e366a38
Compare
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
eb41b0f
to
a843267
Compare
add test for deprecation message cylc install
a843267
to
0beeac4
Compare
cylc/flow/workflow_files.py
Outdated
link = flow_file.resolve() | ||
if link.parent == flow_file.parent: |
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.
This would allow
myflow
|-- something.cylc
|-- flow.cylc -> something.cylc
`-- suite.rc
which is equivalent to having distinct flow.cylc
and suite.rc
files in the same run dir.
Perhaps it should be something like
if flow_file.resolve() == flow_file.parent / WorkflowFiles.SUITE_RC:
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.
This case (I think) is covered by the following condition: if flow_file.parent.joinpath(WorkflowFiles.SUITE_RC).exists():
.
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.
It would be, but it will return False
before getting to that.
See my suggestion: https://github.com/cylc/cylc-flow/pull/4506/files#r760191324
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.
Sorry for my confusion! All testing for me was raising the error....
The return False does not return before that (where it should!) because flow_file.parent
needed a resolve()
on the end to hit the false.
Will go with your suggestion (adding a resolve()), thanks @MetRonnie
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.
Ok, coming back to this (confusion after your suggestion was added by Tim so it wasn't visible to me). This suggestion will forbid symlinking elsewhere.
Going to push a change which I think now covers all scenarios, based on your if flow_file.resolve() == flow_file.parent / WorkflowFiles.SUITE_RC:
suggestion.
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
…low into remove-suite-flow-symlink
@wxtim I've made some logic changes since your approval, sorry! So requesting re-review. |
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
|
||
if log_msg: | ||
assert log_msg in caplog.messages | ||
def test_is_forbidden_symlink_returns_false_for_non_symlink(tmp_path): |
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.
Can we test some scenarios where is_forbidden
→ True
?
Apart from Codecov highlighting it, I would expect there to be ~2 (sets of/parameters?) tests for a function returning a boolean.
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.
There are currently 2 tests covering this scenario, is forbidden → True
. I think that the two that are there are sufficient but let me know if you'd like more added. I'll have a look at why the codecov thinks otherwise.
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.
The code could probably be refactored to simplify it, but that can wait.
Removes the
flow.cylc
symlink created when using asuite.rc
file. This also enabled a refactor of duplicate logic from #4497.These changes close #4500
Milestone is 8.0rc1 to give time for any unforeseen problems to surface.
Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.setup.py
andconda-environment.yml
.