-
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
Disallow nested run directories #3852
Conversation
cylc/flow/suite_files.py
Outdated
if (os.path.isfile(os.path.join(path, SuiteFiles.FLOW_FILE)) or | ||
os.path.isdir(os.path.join(path, SuiteFiles.Service.DIRNAME)) or | ||
os.path.isfile(os.path.join(path, SuiteFiles.SUITE_RC))): | ||
return True |
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.
Instead of checking for the existence of the .service
dir, should we check that .sevice/source
is an existing 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.
Existing or valid?
Are you suggesting we disallow flows inside existing valid run directories, but we allow them inside existing invalid ones?
That seems untidy at best, to me (is there a use 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.
I was wondering whether testing for .service/source
was a more appropriate gauge of whether the directory was valid, but I guess just .service
is good enough
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.
Actually checking for flow.cylc
or suite.rc
or .service/
as above might be overkill. Detecting .service/
is probably sufficient isn't it? I would say the presence of a service directory is really what defines a Cylc run directory, not the presence of a flow config file, which can appear in other places too.
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.
I see... Though checking for flow.cylc
will catch if you tried to register a suite in a sub dir of an unregistered suite. But come to think of it, I suppose that isn't desirable, actually? It's only the registered ones we care about here?
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.
I've pushed a new commit removes the check for flow.cylc
/ suite.rc
Still 2 unresolved points Oliver commented on the issue:
|
We can already run a suite in a temp dir using
Presumably by in-place installations you mean run a flow in-place without installing it to the normal cylc-run location? The trouble is, that's not discoverable by FS scan and other tools. But maybe that's OK if we have real built-in support for sub-suites, so that you're actually not supposed to be able to discover them as independent entities as they are now.
I suppose
I'd rather that got removed by the PR that makes it obsolete. |
f236fc5
to
0a9b21e
Compare
I called it "local run-dir mode", which makes a bit more sense than "local run mode". That PR was actually aborted and superseded by #2935 ("support symlinked alternate run-directories") which is where the |
I agree, in which case (in light of my previous comment) I'm a bit confused about your statement Might be a good time to remove the |
By "run in place" model, do you mean "run a suite that has not been registered, by |
This should become obsolete with the upcoming changes to symlink run dirs (#3688) and the Can remove later.
This is what I was thinking of. We used to have the ability to write and run a workflow in an arbitrary directory without symlinking anything into cylc-run. I think it "worked by accident" but proved to have some valid use cases for fire-and-forget suites, Ok, don't have to worry about that then, can come back to it later if there is demand. |
👍 I've added a note to that issue. #3688 (comment) |
That's right. But when I went to restore that capability (and make it official) we ended up with the
Yep. |
Because flow.cylc can be in a non-run dir
Had a go at testing this, for the expected use case $ tree -a
.
└── a
├── b
│ └── suite.rc
└── suite.rc
2 directories, 2 files
$ cylc reg a a
2020-10-13T17:39:28+01:00 WARNING - The filename "suite.rc" is deprecated in
favor of "flow.cylc". Symlink created.
REGISTERED a -> /Users/oliver/cylc-run/a
$ cylc reg a/b a/b
SuiteServiceFileError: Nested run directories not allowed - cannot register suite name "a/b" as a is already a valid run directory. However, you can still register nested suites by doing it the other way around: $ tree -a
.
└── a
├── b
│ └── suite.rc
└── suite.rc
2 directories, 2 files
$ cylc reg a/b a/b
2020-10-13T17:38:41+01:00 WARNING - The filename "suite.rc" is deprecated in
favor of "flow.cylc". Symlink created.
REGISTERED a/b -> /Users/oliver/cylc-run/a/b
$ cylc reg a a
2020-10-13T17:38:44+01:00 WARNING - The filename "suite.rc" is deprecated in
favor of "flow.cylc". Symlink created.
REGISTERED a -> /Users/oliver/cylc-run/a
$ tree -a
.
└── a
├── .service
│ └── source -> ..
├── b
│ ├── .service
│ │ └── source -> ..
│ ├── flow.cylc -> /Users/oliver/cylc-run/a/b/suite.rc
│ └── suite.rc
├── flow.cylc -> /Users/oliver/cylc-run/a/suite.rc
└── suite.rc
6 directories, 4 files This isn't a facetious example as with hierarchically registered suites it's quite likely that someone might try to absentmindedly register a suite somewhere in the hierarchy where it's not meant to be. Blocking registration in this case would involve searching down the file tree in search of If only we had a nice convenient database of registrations 😈 (Cylc 6 joke). |
A classic 🤣 |
The default depth that cylc-flow/cylc/flow/network/scan.py Line 106 in fe83115
|
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.
🎉 nice
These changes close #3835
This PR prevents registering a suite in a subdirectory of another run directory, or registering a suite in a directory whose children contain a run directory. It does this by checking upwards for the existence of a flow config file or a
.service
dir in successive parent dirs up to the cylc run dir, as well as checking downwards in subdirectories to a depth of 4 (the defaultcylc scan
depth).Requirements check-list
CONTRIBUTING.md
and added my name as a Code Contributor.