-
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 --directory
option for cylc install
#4823
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -22,18 +22,25 @@ | |||||
|
||||||
The workflow can then be started, stopped, and targeted by name. | ||||||
|
||||||
Normal installation creates a directory "~/cylc-run/WORKFLOW_NAME/", with a run | ||||||
directory "~/cylc-run/WORKFLOW_NAME/run1". A "_cylc-install/source" symlink to | ||||||
the source directory will be created in the WORKFLOW_NAME directory. | ||||||
Normal installation creates a directory "~/cylc-run/<workflow>/", with a run | ||||||
directory "~/cylc-run/<workflow>/run1". A "_cylc-install/source" symlink to | ||||||
the source directory will be created in the workflow directory. | ||||||
Any files or directories (excluding .git, .svn) from the source directory are | ||||||
copied to the new run directory. | ||||||
A ".service" directory will also be created and used for server authentication | ||||||
files at run time. | ||||||
|
||||||
If the argument WORKFLOW_NAME is used, Cylc will search for the workflow in the | ||||||
list of directories given by "global.cylc[install]source dirs", and install the | ||||||
first match. Otherwise, the workflow in the current working directory, or the | ||||||
one specified by the "--directory" option, will be installed. | ||||||
The SOURCE argument accepts three types of path: | ||||||
* implicit relative path (e.g. "foo/bar") - Cylc will search for the | ||||||
workflow source in the list of directories given by | ||||||
"global.cylc[install]source dirs", and install the first match. | ||||||
* explicit relative path (e.g. "./foo/bar") - Cylc will install the workflow | ||||||
from the source that is relative to the current working directory. | ||||||
* absolute path (e.g. "~/foo/bar") - Cylc will install the workflow from the | ||||||
source given by the path. | ||||||
|
||||||
If the SOURCE argument is not supplied, Cylc will install the workflow from | ||||||
the source in the current working directory. | ||||||
|
||||||
Workflow names can be hierarchical, corresponding to the path under ~/cylc-run. | ||||||
|
||||||
|
@@ -44,36 +51,44 @@ | |||||
# this will increment) | ||||||
$ cylc install dogs/fido | ||||||
|
||||||
# Install $PWD/flow.cylc as "rabbit", if $PWD is ~/bunny/rabbit, with | ||||||
# Install $PWD as "rabbit", if $PWD is ~/bunny/rabbit, with | ||||||
# run directory ~/cylc-run/rabbit/run1 | ||||||
$ cylc install | ||||||
|
||||||
# Install $PWD/flow.cylc as "rabbit", if $PWD is ~/bunny/rabbit, with | ||||||
# Install $PWD as "rabbit", if $PWD is ~/bunny/rabbit, with | ||||||
# run directory ~/cylc-run/rabbit (note: no "run1" sub-directory) | ||||||
$ cylc install --no-run-name | ||||||
|
||||||
# Install $PWD/flow.cylc as "fido", regardless of what $PWD is, with | ||||||
# Install $PWD as "fido", regardless of what $PWD is called, with | ||||||
# run directory ~/cylc-run/fido/run1 | ||||||
$ cylc install --flow-name=fido | ||||||
$ cylc install --workflow-name=fido | ||||||
|
||||||
# Install $PWD/bunny/rabbit/flow.cylc as "rabbit", with run directory | ||||||
# Install $PWD/bunny/rabbit/ as "rabbit", with run directory | ||||||
# ~/cylc-run/rabbit/run1 | ||||||
$ cylc install --directory=bunny/rabbit | ||||||
$ cylc install ./bunny/rabbit | ||||||
|
||||||
# Install /home/somewhere/badger as "badger", with run directory | ||||||
# ~/cylc-run/badger/run1 | ||||||
$ cylc install /home/somewhere/badger | ||||||
|
||||||
# Install $PWD/flow.cylc as "cats", if $PWD is ~/cats, overriding the | ||||||
# run1, run2, run3 etc. structure with run directory ~/cylc-run/cats/paws | ||||||
# Install $PWD as "cats", if $PWD is ~/cats, with run directory | ||||||
# ~/cylc-run/cats/paws | ||||||
$ cylc install --run-name=paws | ||||||
|
||||||
The same workflow can be installed with multiple names; this results in | ||||||
multiple workflow run directories that link to the same workflow definition. | ||||||
|
||||||
""" | ||||||
|
||||||
from pathlib import Path | ||||||
from typing import Optional, TYPE_CHECKING, Dict, Any | ||||||
|
||||||
from cylc.flow import iter_entry_points | ||||||
from cylc.flow.exceptions import PluginError, UserInputError | ||||||
from cylc.flow.option_parsers import CylcOptionParser as COP | ||||||
from cylc.flow.option_parsers import ( | ||||||
CylcOptionParser as COP, | ||||||
) | ||||||
from cylc.flow.pathutil import EXPLICIT_RELATIVE_PATH_REGEX, expand_path | ||||||
from cylc.flow.workflow_files import ( | ||||||
install_workflow, search_install_source_dirs, parse_cli_sym_dirs | ||||||
) | ||||||
|
@@ -86,48 +101,47 @@ | |||||
def get_option_parser(): | ||||||
parser = COP( | ||||||
__doc__, comms=True, prep=True, | ||||||
argdoc=[('[WORKFLOW_NAME]', 'Workflow source name')] | ||||||
argdoc=[('[SOURCE]', 'Path to workflow source')] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
) | ||||||
|
||||||
parser.add_option( | ||||||
"--flow-name", | ||||||
help="Install into ~/cylc-run/<workflow_name>/runN ", | ||||||
"--workflow-name", "-n", | ||||||
help="Install into ~/cylc-run/<WORKFLOW_NAME>/runN ", | ||||||
action="store", | ||||||
metavar="WORKFLOW_NAME", | ||||||
default=None, | ||||||
dest="workflow_name") | ||||||
|
||||||
parser.add_option( | ||||||
"--directory", "-C", | ||||||
help="Install the workflow found in path specfied.", | ||||||
action="store", | ||||||
metavar="PATH/TO/FLOW", | ||||||
default=None, | ||||||
dest="source") | ||||||
|
||||||
parser.add_option( | ||||||
"--symlink-dirs", | ||||||
help=( | ||||||
"Enter a list, in the form 'log=path/to/store, share = $...'" | ||||||
". Use this option to override local symlinks for directories run," | ||||||
" log, work, share, share/cycle, as configured in global.cylc. " | ||||||
"Enter an empty list \"\" to skip making localhost symlink dirs." | ||||||
"Enter a comma-delimited list, in the form " | ||||||
"'log=path/to/store, share = $HOME/some/path, ...'. " | ||||||
"Use this option to override the global.cylc configuration for " | ||||||
"local symlinks for the run, log, work, share and " | ||||||
"share/cycle directories. " | ||||||
"Enter an empty list '' to skip making localhost symlink dirs." | ||||||
), | ||||||
action="store", | ||||||
dest="symlink_dirs" | ||||||
) | ||||||
|
||||||
parser.add_option( | ||||||
"--run-name", | ||||||
help="Name the run.", | ||||||
help=( | ||||||
"Give the run a custom name instead of automatically numbering it." | ||||||
), | ||||||
action="store", | ||||||
metavar="RUN_NAME", | ||||||
default=None, | ||||||
dest="run_name") | ||||||
|
||||||
parser.add_option( | ||||||
"--no-run-name", | ||||||
help="Install the workflow directly into ~/cylc-run/<workflow_name>", | ||||||
help=( | ||||||
"Install the workflow directly into ~/cylc-run/<workflow_name>, " | ||||||
"without an automatic run number or custom run name." | ||||||
), | ||||||
action="store_true", | ||||||
default=False, | ||||||
dest="no_run_name") | ||||||
|
@@ -137,6 +151,22 @@ def get_option_parser(): | |||||
return parser | ||||||
|
||||||
|
||||||
def get_source_location(path: Optional[str]) -> Path: | ||||||
"""Return the workflow source location as an absolute path. | ||||||
|
||||||
Note: does not check that the source actually exists. | ||||||
""" | ||||||
if path is None: | ||||||
return Path.cwd() | ||||||
path = path.strip() | ||||||
expanded_path = Path(expand_path(path)) | ||||||
if expanded_path.is_absolute(): | ||||||
return expanded_path | ||||||
if EXPLICIT_RELATIVE_PATH_REGEX.match(path): | ||||||
return Path.cwd() / expanded_path | ||||||
return search_install_source_dirs(expanded_path) | ||||||
|
||||||
|
||||||
@cli_function(get_option_parser) | ||||||
def main(parser, opts, reg=None): | ||||||
install(parser, opts, reg) | ||||||
|
@@ -150,25 +180,12 @@ def install( | |||||
"options --no-run-name and --run-name are mutually exclusive." | ||||||
) | ||||||
|
||||||
if reg is None: | ||||||
source = opts.source | ||||||
else: | ||||||
if opts.source: | ||||||
raise UserInputError( | ||||||
"WORKFLOW_NAME and --directory are mutually exclusive." | ||||||
) | ||||||
source = search_install_source_dirs(reg) | ||||||
workflow_name = opts.workflow_name or reg | ||||||
|
||||||
source = get_source_location(reg) | ||||||
for entry_point in iter_entry_points( | ||||||
'cylc.pre_configure' | ||||||
): | ||||||
try: | ||||||
if source: | ||||||
entry_point.resolve()(srcdir=source, opts=opts) | ||||||
else: | ||||||
from pathlib import Path | ||||||
entry_point.resolve()(srcdir=Path().cwd(), opts=opts) | ||||||
entry_point.resolve()(srcdir=source, opts=opts) | ||||||
except Exception as exc: | ||||||
# NOTE: except Exception (purposefully vague) | ||||||
# this is to separate plugin from core Cylc errors | ||||||
|
@@ -185,8 +202,8 @@ def install( | |||||
cli_symdirs = parse_cli_sym_dirs(opts.symlink_dirs) | ||||||
|
||||||
source_dir, rundir, _workflow_name = install_workflow( | ||||||
workflow_name=workflow_name, | ||||||
source=source, | ||||||
workflow_name=opts.workflow_name, | ||||||
run_name=opts.run_name, | ||||||
no_run_name=opts.no_run_name, | ||||||
cli_symlink_dirs=cli_symdirs | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just curious, is this path format officially called "explicit relative"? If you invented the term, I quite like it 👍 Although arguably it's really an absolute path that goes through $PWD.
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 can't seem to find any terminology for relative paths for differentiating between whether they start with
./
or not. Explicit and implicit seems to be something one of us (maybe Tim, as author of the issue #4676) came up with.Maybe we should avoid calling relative paths that don't start with
./
as relative paths at all; maybe calling them workflow source names would be less confusing? The arg could then beSOURCE_NAME | PATH
wherePATH
can be relative or absolute but must start with./
if relative.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 trouble is that conflicts with standard unix terminology, where a relative path doesn't have to start with
./
.IMO
./blah
and../blah
should really be considered absolute paths, where.
is short for$PWD
which expands to an absolute path. Like~/blah
is an absolute path even though it is relative to$HOME
. But, that doesn't seem to be the prevailing opinion out there.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.
MB but I think it's valid and helpful here.
I don't think that's correct, technically
.
and..
are relative paths implemented at the FS level and visible in FS listings. So.
is not short for$PWD
though it happens to resolve to the same thing.$PWD/foo
- the$PWD
is expanded by the shell../foo
- the./
is resolved by the FS.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.
Technically true, but I doubt that matters to users.
BTW I didn't mean that
.
is literally short for$PWD
and, like the shell variable, expanded by the shell ... just that it is short for the present working directory. A true relative path is implicit. Presumably the main reason for the existence of..
is to make changing up a level easier, and.
, to force the behaviour of programs that don't interpret (implicit) relative paths properly. So I'd still argue thatrel/path
is a proper relative path, but./rel/path
is kind of an absolute path masquerading as a relative 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.
Explicit relative and absolute paths are handled the same by the CLI so this disparity is not user facing. This is internal technical documentation in a docstring.
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.
(Which still needs to be understood at a glance by future developers).