Esempio n. 1
0
def get_option_parser():
    """Augment options parser to current context."""
    parser = COP(__doc__, argdoc=[('REG', 'Suite name')], comms=True)

    delta_keys = list(DELTAS_MAP)
    pb_topics = ("Directly published data-store topics include: '" +
                 ("', '").join(delta_keys[:-1]) + "' and '" + delta_keys[-1] +
                 "'.")
    parser.add_option(
        "-T",
        "--topics",
        help="Specify a comma delimited list of subscription topics. " +
        pb_topics,
        action="store",
        dest="topics",
        default='workflow')

    parser.add_option("-o",
                      "--once",
                      help="Show a single publish then exit.",
                      action="store_true",
                      default=False,
                      dest="once")

    return parser
Esempio n. 2
0
def get_option_parser():
    parser = COP(
        __doc__,
        comms=True,
        argdoc=[
            ("WORKFLOW_ID", "Workflow ID"),
            ("MSG", "External trigger message"),
            ("TRIGGER_ID", "Unique trigger ID"),
        ],
    )

    parser.add_option("--max-tries",
                      help="Maximum number of send attempts "
                      "(default %s)." % MAX_N_TRIES,
                      metavar="INT",
                      action="store",
                      default=MAX_N_TRIES,
                      dest="max_n_tries")

    parser.add_option("--retry-interval",
                      help="Delay in seconds before retrying "
                      "(default %s)." % RETRY_INTVL_SECS,
                      metavar="SEC",
                      action="store",
                      default=RETRY_INTVL_SECS,
                      dest="retry_intvl_secs")

    return parser
Esempio n. 3
0
def main(parser: COP, options: 'Values', workflow_id: str) -> None:
    workflow_id, *_ = parse_id(
        workflow_id,
        constraint='workflows',
    )

    output_options = [
        options.show_raw, options.show_summary, options.html_summary
    ]
    if output_options.count(True) > 1:
        parser.error('Cannot combine output formats (choose one)')
    if not any(output_options):
        # No output specified - choose summary by default
        options.show_summary = True

    run_db = _get_dao(workflow_id)
    row_buf = format_rows(*run_db.select_task_times())
    with smart_open(options.output_filename) as output:
        if options.show_raw:
            output.write(row_buf.getvalue())
        else:
            summary: TimingSummary
            if options.show_summary:
                summary = TextTimingSummary(row_buf)
            elif options.html_summary:
                summary = HTMLTimingSummary(row_buf)
            summary.write_summary(output)
Esempio n. 4
0
def get_option_parser():
    parser = COP(__doc__,
                 comms=True,
                 multitask=True,
                 argdoc=[('REG', 'Suite name'),
                         ('[TASK_GLOB ...]', 'Task matching patterns')])

    parser.add_option("-s",
                      "--state",
                      metavar="STATE",
                      help="Reset task state to STATE, can be %s" %
                      (', '.join(TASK_STATUSES_CAN_RESET_TO)),
                      choices=list(TASK_STATUSES_CAN_RESET_TO),
                      action="store",
                      dest="state")

    parser.add_option(
        "--output",
        "-O",
        metavar="OUTPUT",
        help=("Find task output by message string or trigger string, " +
              "set complete or incomplete with !OUTPUT, " +
              "'*' to set all complete, '!*' to set all incomplete. " +
              "Can be used more than once to reset multiple task outputs."),
        action="append",
        default=[],
        dest="outputs")

    return parser
Esempio n. 5
0
def get_option_parser():
    parser = COP(
        __doc__,
        comms=True,
        multitask=True,
        multiworkflow=True,
        argdoc=[('ID [ID ...]', 'Cycle/Family/Task ID(s)')],
    )

    parser.add_option("-o",
                      "--output",
                      metavar="OUTPUT",
                      help="Set OUTPUT (default \"succeeded\") completed.",
                      action="append",
                      default=None,
                      dest="outputs")

    parser.add_option("-f",
                      "--flow",
                      metavar="FLOW",
                      help="Number of the flow to attribute the outputs.",
                      action="store",
                      default=None,
                      dest="flow_num")

    return parser
Esempio n. 6
0
def install(
    parser: COP, opts: 'Values', reg: Optional[str] = None
) -> None:
    if opts.no_run_name and opts.run_name:
        parser.error(
            "options --no-run-name and --run-name are mutually exclusive.")

    if reg is None:
        source = opts.source
    else:
        if opts.source:
            parser.error("REG and --directory are mutually exclusive.")
        source = search_install_source_dirs(reg)
    flow_name = opts.flow_name or 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)
        except Exception as exc:
            # NOTE: except Exception (purposefully vague)
            # this is to separate plugin from core Cylc errors
            raise PluginError(
                'cylc.pre_configure',
                entry_point.name,
                exc
            ) from None

    source_dir, rundir, _flow_name = install_workflow(
        flow_name=flow_name,
        source=source,
        run_name=opts.run_name,
        no_run_name=opts.no_run_name,
        no_symlinks=opts.no_symlinks
    )

    for entry_point in iter_entry_points(
        'cylc.post_install'
    ):
        try:
            entry_point.resolve()(
                srcdir=source_dir,
                opts=opts,
                rundir=str(rundir)
            )
        except Exception as exc:
            # NOTE: except Exception (purposefully vague)
            # this is to separate plugin from core Cylc errors
            raise PluginError(
                'cylc.post_install',
                entry_point.name,
                exc
            ) from None
def main():
    parser = COP(__doc__, comms=True, argdoc=[('REG', 'Suite name')])

    (options, args) = parser.parse_args()
    suite = args[0]

    pclient = SuiteRuntimeClient(suite, options.owner, options.host,
                                 options.port)
    print(pclient('get_cylc_version', timeout=options.comms_timeout))
Esempio n. 8
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
Esempio n. 9
0
def get_option_parser():
    parser = COP(__doc__,
                 argdoc=[('[DIR]', 'Target directory.'),
                         ('[RESOURCES...]',
                          'Resources to extract (default all).')])

    parser.add_option('--list', default=False, action='store_true')

    return parser
Esempio n. 10
0
def get_option_parser():
    parser = COP(__doc__, argdoc=[])

    parser.add_option("-i",
                      "--item",
                      metavar="[SEC...]ITEM",
                      help="Item or section to print (multiple use allowed).",
                      action="append",
                      dest="item",
                      default=[])

    parser.add_option(
        "--sparse",
        help="Only print items explicitly set in the config files.",
        action="store_true",
        default=False,
        dest="sparse")

    parser.add_option("-p",
                      "--python",
                      help="Print native Python format.",
                      action="store_true",
                      default=False,
                      dest="pnative")

    parser.add_option("--print-run-dir",
                      help="Print the configured top level run directory.",
                      action="store_true",
                      default=False,
                      dest="run_dir")

    return parser
Esempio n. 11
0
def get_option_parser():
    parser = COP(__doc__, argdoc=[('WORKFLOW', 'Workflow name or ID')])
    parser.add_option(
        "-r",
        "--raw",
        help="Show raw timing output suitable for custom diagnostics.",
        action="store_true",
        default=False,
        dest="show_raw")
    parser.add_option("-s",
                      "--summary",
                      help="Show textual summary timing output for tasks.",
                      action="store_true",
                      default=False,
                      dest="show_summary")
    parser.add_option("-w",
                      "--web-summary",
                      help="Show HTML summary timing output for tasks.",
                      action="store_true",
                      default=False,
                      dest="html_summary")
    parser.add_option("-O",
                      "--output-file",
                      help="Output to a specific file",
                      action="store",
                      default=None,
                      dest="output_filename")

    return parser
Esempio n. 12
0
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",
                      dest="disp_form")
    parser.add_option("-t",
                      "--tasks",
                      help="Task states only.",
                      action="store_const",
                      const="tasks",
                      dest="disp_form")
    parser.add_option("-r",
                      "--raw",
                      "--raw-format",
                      help='Display raw format.',
                      action="store_const",
                      const="raw",
                      dest="disp_form")
    parser.add_option(
        "-s",
        "--sort",
        help="Task states only; sort by cycle point instead of name.",
        action="store_true",
        default=False,
        dest="sort_by_cycle")

    return parser
def test_help_nocolor(monkeypatch):
    """Test for no colorization in 'cylc cmd --help --color=never'."""
    # This colorization is done on the fly when help is printed.
    monkeypatch.setattr(sys, "argv", ['cmd', 'foo', '--color=never'])
    parser = COP(USAGE_WITH_COMMENT)
    parser.parse_args(None)
    assert parser.values.color == "never"
    f = io.StringIO()
    with redirect_stdout(f):
        parser.print_help()
    assert (f.getvalue()).startswith("Usage: " + USAGE_WITH_COMMENT)
Esempio n. 14
0
def main(parser: COP, options: 'Values', workflow_id1: str, workflow_id2: str):
    workflow_id_1, _, workflow_file_1_ = parse_id(
        workflow_id1,
        src=True,
        constraint='workflows',
    )
    workflow_id_2, _, workflow_file_2_ = parse_id(
        workflow_id2,
        src=True,
        constraint='workflows',
    )
    if workflow_file_1_ == workflow_file_2_:
        parser.error("You can't diff a single workflow.")
    print(f"Parsing {workflow_id_1} ({workflow_file_1_})")
    template_vars = load_template_vars(
        options.templatevars, options.templatevars_file
    )
    config1 = WorkflowConfig(
        workflow_id_1, workflow_file_1_, options, template_vars
    ).cfg
    print(f"Parsing {workflow_id_2} ({workflow_file_2_})")
    config2 = WorkflowConfig(
        workflow_id_2, workflow_file_2_, options, template_vars,
        is_reload=True
    ).cfg

    if config1 == config2:
        print(
            f"Workflow definitions {workflow_id_1} and {workflow_id_2} are "
            f"identical"
        )
        sys.exit(0)

    print(f"Workflow definitions {workflow_id_1} and {workflow_id_2} differ")

    workflow1_only = {}  # type: ignore
    workflow2_only = {}  # type: ignore
    diff_1_2 = {}  # type: ignore
    # TODO: this whole file could do wih refactoring at some point

    diffdict(config1, config2, workflow1_only, workflow2_only, diff_1_2)

    if n_oone > 0:
        print(f'\n{n_oone} items only in {workflow_id_1} (<)')
        prdict(workflow1_only, '<', nested=options.nested)

    if n_otwo > 0:
        print(f'\n{n_otwo} items only in {workflow_id_2} (>)')
        prdict(workflow2_only, '>', nested=options.nested)

    if n_diff > 0:
        print(f'\n{n_diff} common items differ {workflow_id_1}(<) '
              f'{workflow_id_2}(>)')
        prdict(diff_1_2, '', diff=True, nested=options.nested)
Esempio n. 15
0
def get_option_parser():
    parser = COP(__doc__, comms=True, argdoc=[
        ('WORKFLOW', 'Workflow name or ID'),
        ('METHOD', 'Network API function name')])

    parser.add_option(
        '-n', '--no-input',
        help='Do not read from STDIN, assume null input',
        action='store_true', dest='no_input')

    return parser
Esempio n. 16
0
def get_option_parser():
    parser = COP(
        __doc__, comms=True, multitask_nocycles=True,
        argdoc=[
            ("REG", "Workflow name"),
            ('TASK-GLOB [...]', 'Task match pattern')])
    parser.add_option(
        "--output", metavar="OUTPUT",
        help="Set task output OUTPUT completed, defaults to 'succeeded'.",
        action="append", dest="outputs")
    return parser
Esempio n. 17
0
def get_option_parser():
    parser = COP(
        __doc__, prep=True,
        argdoc=[('SUITE', 'Suite name or path'),
                ('PATTERN', 'Python-style regular expression'),
                ('[PATTERN2...]', 'Additional search patterns')])

    parser.add_option(
        "-x", help="Do not search in the suite bin directory",
        action="store_false", default=True, dest="search_bin")

    return parser
Esempio n. 18
0
def get_option_parser():
    parser = COP(
        __doc__, jset=True, prep=True, icp=True,
        argdoc=[('WORKFLOW1', 'Workflow name or path'),
                ('WORKFLOW2', 'Workflow name or path')])

    parser.add_option(
        "-n", "--nested",
        help="print flow.cylc section headings in nested form.",
        action="store_true", default=False, dest="nested")

    return parser
Esempio n. 19
0
def get_option_parser():
    parser = COP(
        __doc__, jset=True, prep=True, icp=True,
        argdoc=[('SUITE1', 'Suite name or path'),
                ('SUITE2', 'Suite name or path')])

    parser.add_option(
        "-n", "--nested",
        help="print suite.rc section headings in nested form.",
        action="store_true", default=False, dest="nested")

    return parser
Esempio n. 20
0
def get_option_parser():
    parser = COP(__doc__,
                 argdoc=[("REG", "Suite name"),
                         ("[ID ...]", "Checkpoint ID (default=latest)")])

    parser.add_option("-a",
                      "--all",
                      help="Display data of all available checkpoints.",
                      action="store_true",
                      default=False,
                      dest="all_mode")

    return parser
Esempio n. 21
0
def get_option_parser():
    parser = COP(__doc__,
                 argdoc=[('[RESOURCE]', 'Resource to extract.'),
                         ('[DIR]', 'Target directory.')])

    parser.add_option(
        '--list',
        help="List available resources.",
        default=False,
        action='store_true',
    )

    return parser
Esempio n. 22
0
def get_option_parser():
    parser = COP(__doc__, prep=True, jset=True)

    parser.add_option("-e",
                      "--error",
                      help="Exit with error status "
                      "if " + CYLC_VERSION +
                      " is not available on all remote platforms.",
                      action="store_true",
                      default=False,
                      dest="error")

    return parser
Esempio n. 23
0
def get_option_parser():
    parser = COP(
        __doc__, comms=True, multitask=True,
        argdoc=[
            ("REG", "Suite name"),
            ('TASK_GLOB [...]', 'Task matching patterns')])

    parser.add_option(
        "--no-spawn",
        help="Do not spawn successors before removal.",
        action="store_true", default=False, dest="no_spawn")

    return parser
Esempio n. 24
0
def get_option_parser():
    parser = COP(
        __doc__, comms=True, multitask_nocycles=True,
        argdoc=[
            ('REG', 'Suite name'),
            ('[TASK_GLOB ...]', 'Task matching patterns')])

    parser.add_option(
        "-r", "--reflow",
        help="Start a new flow from the triggered task.",
        action="store_true", default=False, dest="reflow")

    return parser
Esempio n. 25
0
def get_option_parser() -> COP:
    parser = COP(__doc__,
                 comms=True,
                 multitask=True,
                 argdoc=[('REG', "Workflow name"),
                         ('[TASK_GLOB ...]', "Task matching patterns")])

    parser.add_option("--after",
                      help="Hold all tasks after this cycle point.",
                      metavar="CYCLE_POINT",
                      action="store",
                      dest="hold_point_string")

    return parser
Esempio n. 26
0
def get_option_parser():
    parser = COP(
        __doc__, comms=True, multitask=True,
        argdoc=[
            ('REG', 'Workflow name'),
            ('[TASK_NAME or TASK_GLOB ...]', 'Task names or match patterns')])

    parser.add_option('--list-prereqs', action="store_true", default=False,
                      help="Print a task's pre-requisites as a list.")

    parser.add_option('--json', action="store_true", default=False,
                      help="Print output in JSON format.")

    return parser
Esempio n. 27
0
def get_option_parser():
    parser = COP(
        __doc__, comms=True,
        argdoc=[
            ('[REG]', 'Suite name'),
            ('[TASK-JOB]', 'Task job identifier CYCLE/TASK_NAME/SUBMIT_NUM'),
            ('[[SEVERITY:]MESSAGE ...]', 'Messages')])
    parser.add_option(
        '-s', '--severity', '-p', '--priority',
        metavar='SEVERITY',
        help='Set severity levels for messages that do not have one',
        action='store', dest='severity')

    return parser
Esempio n. 28
0
def get_option_parser():
    parser = COP(__doc__,
                 comms=True,
                 multitask=True,
                 argdoc=[("REG", "Suite name"),
                         ('[TASK_GLOB ...]', 'Task matching patterns')])

    parser.add_option("--after",
                      help="Hold whole suite AFTER this cycle point.",
                      metavar="CYCLE_POINT",
                      action="store",
                      dest="hold_point_string")

    return parser
Esempio n. 29
0
def get_option_parser():
    parser = COP(__doc__,
                 comms=True,
                 multitask=True,
                 argdoc=[('REG', 'Suite name'),
                         ('[TASK_GLOB ...]', 'Task matching patterns')])

    parser.add_option("-s",
                      "--succeeded",
                      help="Allow polling of succeeded tasks.",
                      action="store_true",
                      default=False,
                      dest="poll_succ")

    return parser
Esempio n. 30
0
def get_option_parser() -> COP:
    parser = COP(__doc__,
                 comms=True,
                 multitask=True,
                 argdoc=[('REG', "Workflow name"),
                         ('[TASK_GLOB ...]', "Task matching patterns")])

    parser.add_option(
        "--all",
        help=(
            "Release all held tasks and remove the 'hold after cycle point', "
            "if set."),
        action="store_true",
        dest="release_all")

    return parser