Skip to content

Commit

Permalink
Support alt cylc-run location.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Jan 29, 2019
1 parent 9ca798d commit 423de83
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 8 additions & 3 deletions bin/cylc-register
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ def main():
("[PATH]", "Suite definition directory (defaults to $PWD)")])

parser.add_option(
"--redirect", help="Allow an existing suite name and run directory "
"to be used with another suite.",
"--redirect", help="Allow an existing suite name and run directory"
" to be used with another suite.",
action="store_true", default=False, dest="redirect")

parser.add_option(
"--run-dir", help="Symlink $HOME/cylc-run/REG to RUNDIR/REG.",
action="store", metavar="RUNDIR", default=None, dest="rundir")

opts, args = parser.parse_args()
if len(args) == 2:
reg, src = args
Expand All @@ -79,7 +83,8 @@ def main():
src = None
else:
reg = src = None
SuiteSrvFilesManager().register(reg, src, redirect=opts.redirect)
SuiteSrvFilesManager().register(
reg, src, redirect=opts.redirect, rundir=opts.rundir)


if __name__ == "__main__":
Expand Down
12 changes: 10 additions & 2 deletions lib/cylc/suite_srv_files_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def parse_suite_arg(self, options, arg):
name = os.path.basename(os.path.dirname(arg))
return name, path

def register(self, reg=None, source=None, redirect=False):
def register(self, reg=None, source=None, redirect=False, rundir=None):
"""Register a suite, or renew its registration.
Create suite service directory and symlink to suite source location.
Expand Down Expand Up @@ -459,7 +459,15 @@ def register(self, reg=None, source=None, redirect=False):

# Create service dir if necessary.
srv_d = self.get_suite_srv_dir(reg)
mkdir_p(srv_d)
if rundir is None:
mkdir_p(srv_d)
else:
suite_run_d, srv_d_name = os.path.split(srv_d)
alt_suite_run_d = os.path.join(rundir, reg)
alt_srv_d = os.path.join(rundir, reg, srv_d_name)
mkdir_p(alt_srv_d)
mkdir_p(os.path.dirname(suite_run_d))
os.symlink(alt_suite_run_d, suite_run_d)

# See if suite already has a source or not
try:
Expand Down

0 comments on commit 423de83

Please sign in to comment.