Example #1
0
def main():
    if not remrun():
        from cylc.flow.option_parsers import CylcOptionParser as COP
        from cylc.flow.task_remote_cmd import remote_tidy

        parser = COP(
            __doc__, argdoc=[("RUND", "The run directory of the suite")]
        )
        remote_tidy(parser.parse_args()[1][0])  # position argument 1, rund
Example #2
0
def scheduler_cli(parser, options, args, is_restart=False):
    """CLI main."""
    reg = args[0]
    # Check suite is not already running before start of host selection.
    try:
        suite_files.detect_old_contact_file(reg)
    except SuiteServiceFileError as exc:
        sys.exit(exc)

    suite_run_dir = get_suite_run_dir(reg)

    if not os.path.exists(suite_run_dir):
        sys.stderr.write(f'suite service directory not found '
                         f'at: {suite_run_dir}\n')
        sys.exit(1)

    # Create auth files if needed.
    suite_files.create_auth_files(reg)

    # Extract job.sh from library, for use in job scripts.
    extract_resources(suite_files.get_suite_srv_dir(reg), ['etc/job.sh'])

    # Check whether a run host is explicitly specified, else select one.
    if not options.host:
        try:
            host = HostAppointer().appoint_host()
        except EmptyHostList as exc:
            if cylc.flow.flags.debug:
                raise
            else:
                sys.exit(str(exc))
        if is_remote_host(host):
            if is_restart:
                base_cmd = ["restart"] + sys.argv[1:]
            else:
                base_cmd = ["run"] + sys.argv[1:]
            # Prevent recursive host selection
            base_cmd.append("--host=localhost")
            return remote_cylc_cmd(base_cmd, host=host)
    if remrun(set_rel_local=True):  # State localhost as above.
        sys.exit()

    try:
        suite_files.get_suite_source_dir(args[0], options.owner)
    except SuiteServiceFileError:
        # Source path is assumed to be the run directory
        suite_files.register(args[0], get_suite_run_dir(args[0]))

    try:
        scheduler = Scheduler(is_restart, options, args)
    except SuiteServiceFileError as exc:
        sys.exit(exc)
    scheduler.start()
Example #3
0
def scheduler_cli(parser, options, args, is_restart=False):
    """CLI main."""
    # Check suite is not already running before start of host selection.
    try:
        SuiteSrvFilesManager().detect_old_contact_file(args[0])
    except SuiteServiceFileError as exc:
        sys.exit(exc)

    # Create auth files if needed.
    SuiteSrvFilesManager().create_auth_files(args[0])

    # Check whether a run host is explicitly specified, else select one.
    if not options.host:
        try:
            host = HostAppointer().appoint_host()
        except EmptyHostList as exc:
            if cylc.flow.flags.debug:
                raise
            else:
                sys.exit(str(exc))
        if is_remote_host(host):
            if is_restart:
                base_cmd = ["restart"] + sys.argv[1:]
            else:
                base_cmd = ["run"] + sys.argv[1:]
            # Prevent recursive host selection
            base_cmd.append("--host=localhost")
            return remote_cylc_cmd(base_cmd, host=host)
    if remrun(set_rel_local=True):  # State localhost as above.
        sys.exit()

    try:
        SuiteSrvFilesManager().get_suite_source_dir(args[0], options.owner)
    except SuiteServiceFileError:
        # Source path is assumed to be the run directory
        SuiteSrvFilesManager().register(args[0], get_suite_run_dir(args[0]))

    try:
        scheduler = Scheduler(is_restart, options, args)
    except SuiteServiceFileError as exc:
        sys.exit(exc)
    scheduler.start()
Example #4
0
def main():
    if not remrun():
        from cylc.flow.option_parsers import CylcOptionParser as COP
        from cylc.flow.task_remote_cmd import remote_init

        parser = COP(
            __doc__,
            argdoc=[
                ("UUID", "UUID of current suite server process"),
                ("RUND", "The run directory of the suite"),
            ],
        )
        parser.add_option(
            "--indirect-comm",
            metavar="METHOD",
            type="choice",
            choices=["ssh"],
            help="specify use of indirect communication via e.g. ssh",
            action="store",
            dest="indirect_comm",
            default=None,
        )
        options, (uuid_str, rund) = parser.parse_args()
        remote_init(uuid_str, rund, indirect_comm=options.indirect_comm)
Example #5
0
For more information about a specific task, such as the current state of
its prerequisites and outputs, see 'cylc [info] show'.

Examples:
 Display the state of all running tasks, sorted by cycle point:
 % cylc [info] dump --tasks --sort SUITE | grep running

 Display the state of all tasks in a particular cycle point:
 % cylc [info] dump -t SUITE | grep 2010082406"""

import sys
if '--use-ssh' in sys.argv[1:]:
    sys.argv.remove('--use-ssh')
    from cylc.flow.remote import remrun
    if remrun():
        sys.exit(0)

from cylc.flow.option_parsers import CylcOptionParser as COP
from cylc.flow.network.client import SuiteRuntimeClient
from cylc.flow.dump import dump_to_stdout
from cylc.flow.terminal import cli_function


def get_option_parser():
    parser = COP(__doc__, comms=True, noforce=True)
    parser.add_option("-g",
                      "--global",
                      help="Global information only.",
                      action="store_const",
                      const="global",
Example #6
0
  Print suite log:
    cylc cat-log foo
  Print task stdout:
    cylc cat-log foo bar.2020
    cylc cat-log -f o foo bar.2020
  Print task stderr:
    cylc cat-log -f e foo bar.2020

Note the --host/user options are not needed to view remote job logs. They are
the general command reinvocation options for sites using ssh-based task
messaging."""

import sys
from cylc.flow.remote import remrun, remote_cylc_cmd, watch_and_kill
# Disallow remote re-invocation of edit mode (result: "ssh HOST vim <file>").
if remrun(abort_if='edit', forward_x11=True):
    sys.exit(0)

import os
import shlex
from contextlib import suppress
from glob import glob
from shlex import quote
from stat import S_IRUSR
from tempfile import NamedTemporaryFile
from subprocess import Popen, PIPE

from cylc.flow.cfgspec.glbl_cfg import glbl_cfg
from cylc.flow.exceptions import UserInputError
import cylc.flow.flags
from cylc.flow.hostuserutil import is_remote
Example #7
0
View a read-only temporary copy of suite NAME's suite.rc file, in your
editor, after optional include-file inlining and Jinja2 preprocessing.

The edit process is spawned in the foreground as follows:
  % <editor> suite.rc
Where <editor> can be set in cylc global config.

For remote host or owner, the suite will be printed to stdout unless
the '-g,--gui' flag is used to spawn a remote GUI edit session.

See also 'cylc [prep] edit'."""

import sys
from cylc.flow.remote import remrun
if remrun(forward_x11=True):
    sys.exit(0)

import os
from tempfile import NamedTemporaryFile
import shlex
from subprocess import call

from cylc.flow.cfgspec.glbl_cfg import glbl_cfg
from cylc.flow.exceptions import CylcError
from cylc.flow.option_parsers import CylcOptionParser as COP
from cylc.flow.parsec.fileparse import read_and_proc
from cylc.flow.suite_files import parse_suite_arg
from cylc.flow.templatevars import load_template_vars
from cylc.flow.terminal import cli_function
Example #8
0
def main(parser, options, job_log_root, *job_log_dirs):
    """CLI main."""
    if not remrun():
        from cylc.flow.batch_sys_manager import BatchSysManager

        BatchSysManager().jobs_kill(job_log_root, job_log_dirs)
Example #9
0
def main():
    if not remrun():
        main_cli()