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

Symlink dirs cli #4250

Merged
merged 9 commits into from
Jul 21, 2021
Merged

Symlink dirs cli #4250

merged 9 commits into from
Jul 21, 2021

Conversation

datamel
Copy link
Contributor

@datamel datamel commented Jun 8, 2021

Adds cli option (--symlink-dirs) for over-riding localhost symlink dirs in global config when executing cylc install.
Removes --no-symlink-dirs option, this is replaced by --symlink-dirs=None

Also moves symlink dirs into install section of config...(these changes close #4219)

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.py and
    conda-environment.yml.
  • Appropriate tests are included (unit and/or functional).
  • Appropriate change log entry included.
  • (master branch) I have opened a documentation PR at symlink dirs cli docs cylc-doc#252

@datamel datamel added this to the cylc-8.0b2 milestone Jun 8, 2021
@datamel datamel self-assigned this Jun 8, 2021
@hjoliver
Copy link
Member

hjoliver commented Jun 9, 2021

Removes --no-symlink-dirs option, this is replaced by --symlink-dirs=None

I'm not sure about this. The original --no-symlink-dirs is pretty unambiguous and intuitive, but --symlink-dirs=None kind of exposes Python internals through the CLI and is less intuitive. Users would more likely guess --symlink-dirs="" (empty string), which does nothing.

@hjoliver
Copy link
Member

hjoliver commented Jun 9, 2021

I'm slight confused about how this works (from a quick test, without examining the code). If I set (e.g.) log and work symlinks for localhost in global.cylc, both symlinks get created by cylc install. If I then override log using cylc install --symlink-dirs, I find that cylc install creates only the overridden log symlink, and the global config work one gets created later by cylc play ??

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.

Tested, looks good:

$ cylc config -i '[install][symlink dirs]'
[[[localhost]]]
    log = $HOME/cylc-log
    run = $HOME/cylc-runn
    share = 
    share/cycle = 
    work = 
$ cylc install one 
INSTALLED one/run1 from .../one
$ cylc install one --symlink-dirs=
INSTALLED one/run2 from .../one
$ cylc install one --symlink-dirs=log=$HOME/cylc-log
INSTALLED one/run3 from .../one
$ tree -l
.
├── _cylc-install
│   └── source -> .../one
│       └── suite.rc
├── run1 -> /cylc-runn/cylc-run/one/run1
│   ├── flow.cylc -> suite.rc
│   ├── log -> /cylc-log/cylc-run/one/run1/log
│   │   ├── install
│   │   │   └── 20210616T102225Z-install.log
│   │   └── version
│   │       ├── uncommitted.diff
│   │       └── vcs.conf
│   └── suite.rc
├── run2
│   ├── flow.cylc -> suite.rc
│   ├── log
│   │   ├── install
│   │   │   └── 20210616T102232Z-install.log
│   │   └── version
│   │       ├── uncommitted.diff
│   │       └── vcs.conf
│   └── suite.rc
├── run3
│   ├── flow.cylc -> suite.rc
│   ├── log -> /cylc-log/cylc-run/one/run3/log
│   │   ├── install
│   │   │   └── 20210616T102253Z-install.log
│   │   └── version
│   │       ├── uncommitted.diff
│   │       └── vcs.conf
│   └── suite.rc
└── runN -> run3  [recursive, not followed]

Tested again overriding run and work, the cylc play overriding has been addressed.

@datamel datamel force-pushed the symlink-dirs-cli branch 2 times, most recently from 65a8564 to 8f0883c Compare June 16, 2021 13:52
@datamel
Copy link
Contributor Author

datamel commented Jun 16, 2021

I'm slight confused about how this works (from a quick test, without examining the code). If I set (e.g.) log and work symlinks for localhost in global.cylc, both symlinks get created by cylc install. If I then override log using cylc install --symlink-dirs, I find that cylc install creates only the overridden log symlink, and the global config work one gets created later by cylc play ??

Sorry about that @hjoliver chatted this through with the team this end and have implemented the following changes.

  • If cylc play-ing an installed flow, localhost symlink dirs will now be skipped.
  • Missing symlink dirs entered on the command line will not fill from global config.
  • --symlink-dirs="" is now the interface for skipping symlink dirs when installing flows.

The dropping of --no-symlink-dirs was an effort to keep the cli concise, rather than bloating with too many options.

Hope this is ok, happy to make changes if you wish.

@oliver-sanders
Copy link
Member

The flake8 rules have just become a little stricter due to #4271, one small violation:

./cylc/flow/workflow_files.py:1383:9: SIM106 Handle error-cases first

Find out more here - https://github.com/MartinThoma/flake8-simplify#rules

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, tests as working, just a few minor suggestions and questions.

cylc/flow/cfgspec/globalcfg.py Outdated Show resolved Hide resolved
cylc/flow/cfgspec/globalcfg.py Outdated Show resolved Hide resolved
cylc/flow/cfgspec/globalcfg.py Outdated Show resolved Hide resolved
cylc/flow/cfgspec/globalcfg.py Outdated Show resolved Hide resolved
cylc/flow/cfgspec/globalcfg.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
@datamel datamel force-pushed the symlink-dirs-cli branch 3 times, most recently from e3af61f to b6d8a98 Compare June 23, 2021 11:49
@datamel datamel mentioned this pull request Jun 29, 2021
7 tasks
@datamel datamel force-pushed the symlink-dirs-cli branch 2 times, most recently from cfffcd1 to c98505b Compare June 29, 2021 22:15
Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

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

I think this is the PR you wanted me to check after #4237 was merged

cylc/flow/pathutil.py Outdated Show resolved Hide resolved
Comment on lines 216 to 219
if path.exists():
# Trying to link to itself; no symlink needed
# (e.g. path's parent is symlink to target's parent)
return False
Copy link
Member

Choose a reason for hiding this comment

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

I think this is needed for the case of share and share/cycle in global.cylc pointing to the same place

[symlink dirs]
   share = ~/sym-share
   share/cycle = ~/sym-share

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 226 has the the return false.

Copy link
Member

Choose a reason for hiding this comment

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

But this checks if the path exists after the target is created.

  1. When the ~/cylc-run/foo/share -> ~/sym-share/cylc-run/foo/share symlink & target already exist, and we're now on share/cycle
  2. The line target.mkdir(...) above will create ~/sym-share/cylc-run/foo/share/cycle.
  3. At this point path exists now - path is ~/cylc-run/foo/share/cycle, but because ~/cylc-run/foo/share is a symlink, path is actually ~/sym-share/cylc-run/foo/share/cycle

(Sorry, the comment in the code doesn't give a good explanation I now realise! And I should have created a test case for share and share/cycle being the same)

cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
tests/unit/conftest.py Outdated Show resolved Hide resolved
tests/unit/conftest.py Outdated Show resolved Hide resolved
tests/unit/conftest.py Outdated Show resolved Hide resolved
cylc/flow/pathutil.py Show resolved Hide resolved
Comment on lines 216 to 219
if path.exists():
# Trying to link to itself; no symlink needed
# (e.g. path's parent is symlink to target's parent)
return False
Copy link
Member

Choose a reason for hiding this comment

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

But this checks if the path exists after the target is created.

  1. When the ~/cylc-run/foo/share -> ~/sym-share/cylc-run/foo/share symlink & target already exist, and we're now on share/cycle
  2. The line target.mkdir(...) above will create ~/sym-share/cylc-run/foo/share/cycle.
  3. At this point path exists now - path is ~/cylc-run/foo/share/cycle, but because ~/cylc-run/foo/share is a symlink, path is actually ~/sym-share/cylc-run/foo/share/cycle

(Sorry, the comment in the code doesn't give a good explanation I now realise! And I should have created a test case for share and share/cycle being the same)

cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
tests/unit/conftest.py Outdated Show resolved Hide resolved
tests/unit/conftest.py Show resolved Hide resolved
tests/unit/conftest.py Outdated Show resolved Hide resolved
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.

Approving this now, assuming @MetRonnie's final comments will be addressed (or countered). Very nice, thanks @datamel 👍

cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
tests/unit/test_workflow_files.py Outdated Show resolved Hide resolved
Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

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

Happy with the response to my review

@oliver-sanders oliver-sanders merged commit acf5fdb into cylc:master Jul 21, 2021
@datamel datamel deleted the symlink-dirs-cli branch July 21, 2021 08:56
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.

symlink dirs: move into [install] section
5 participants