Exemplo n.º 1
0
def get_option_parser(add_std_opts=False):
    """Parse CLI for "cylc play"."""
    parser = COP(PLAY_DOC,
                 icp=True,
                 jset=True,
                 comms=True,
                 argdoc=[WORKFLOW_NAME_ARG_DOC])

    parser.add_option(
        "-n",
        "--no-detach",
        "--non-daemon",
        help="Do not daemonize the scheduler (infers --format=plain)",
        action="store_true",
        dest="no_detach")

    parser.add_option("--profile",
                      help="Output profiling (performance) information",
                      action="store_true",
                      dest="profile_mode")

    parser.add_option(
        "--start-cycle-point",
        "--startcp",
        help=(
            "Set the start cycle point, which may be after the initial cycle "
            "point. If the specified start point is not in the sequence, the "
            "next on-sequence point will be used. "
            "(Not to be confused with the initial cycle point.) "
            "This replaces the Cylc 7 --warm option."),
        metavar="CYCLE_POINT",
        action="store",
        dest="startcp")

    parser.add_option(
        "--final-cycle-point",
        "--fcp",
        help=(
            "Set the final cycle point. "
            "This command line option overrides the workflow "
            "config option '[scheduling]final cycle point'. "
            "Use a value of 'reload' to reload from flow.cylc in a restart."),
        metavar="CYCLE_POINT",
        action="store",
        dest="fcp")

    parser.add_option(
        "--stop-cycle-point",
        "--stopcp",
        help=(
            "Set the stop cycle point. "
            "Shut down after all tasks have PASSED this cycle point. "
            "(Not to be confused with the final cycle point.) "
            "This command line option overrides the workflow "
            "config option '[scheduling]stop after cycle point'. "
            "Use a value of 'reload' to reload from flow.cylc in a restart."),
        metavar="CYCLE_POINT",
        action="store",
        dest="stopcp")

    parser.add_option(
        "--start-task",
        "--starttask",
        "-t",
        help="Start from this task instance. Can be used multiple times "
        "to start from multiple tasks at once. Dependence on tasks with "
        "with cycle points earlier than the earliest start-task will be "
        "ignored. A sub-graph of the workflow will run if selected tasks "
        "do not lead on to the full graph.",
        metavar="NAME.CYCLE_POINT",
        action="append",
        dest="starttask")

    parser.add_option("--pause",
                      help="Pause the workflow immediately on start up.",
                      action="store_true",
                      dest="paused_start")

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

    parser.add_option("-m",
                      "--mode",
                      help="Run mode: live, dummy, simulation (default live).",
                      metavar="STRING",
                      action="store",
                      dest="run_mode",
                      choices=["live", "dummy", "simulation"])

    parser.add_option(
        "--reference-log",
        help="Generate a reference log for use in reference tests.",
        action="store_true",
        default=False,
        dest="genref")

    parser.add_option(
        "--reference-test",
        help="Do a test run against a previously generated reference log.",
        action="store_true",
        default=False,
        dest="reftest")

    # Override standard parser option for specific help description.
    parser.add_option(
        "--host",
        help=("Specify the host on which to start-up the workflow. "
              "If not specified, a host will be selected using "
              "the '[scheduler]run hosts' global config."),
        metavar="HOST",
        action="store",
        dest="host")

    parser.add_option(
        "--format",
        help="The format of the output: 'plain'=human readable, 'json'",
        choices=("plain", "json"),
        default="plain")

    parser.add_option(
        "--main-loop",
        help=("Specify an additional plugin to run in the main loop."
              " These are used in combination with those specified in"
              " [scheduler][main loop]plugins. Can be used multiple times"),
        metavar="PLUGIN_NAME",
        action="append",
        dest="main_loop")

    parser.add_option(
        "--abort-if-any-task-fails",
        help="If set workflow will abort with status 1 if any task fails.",
        action="store_true",
        default=False,
        dest="abort_if_any_task_fails")

    if add_std_opts:
        # This is for the API wrapper for integration tests. Otherwise (CLI
        # use) "standard options" are added later in options.parse_args().
        # They should really be added in options.__init__() but that requires a
        # bit of refactoring because option clashes are handled bass-ackwards
        # ("overrides" are added before standard options).
        parser.add_std_options()

    return parser
Exemplo n.º 2
0
def get_option_parser(is_restart, add_std_opts=False):
    """Parse CLI for "cylc run" or "cylc restart"."""
    if is_restart:
        parser = COP(RESTART_DOC, jset=True, argdoc=[SUITE_NAME_ARG_DOC])
    else:
        parser = COP(RUN_DOC,
                     icp=True,
                     jset=True,
                     argdoc=[SUITE_NAME_ARG_DOC, START_POINT_ARG_DOC])

    parser.add_option(
        "-n",
        "--no-detach",
        "--non-daemon",
        help="Do not daemonize the suite (infers --format=plain)",
        action="store_true",
        dest="no_detach")

    parser.add_option(
        "-a",
        "--no-auto-shutdown",
        help="Do not shut down"
        " the suite automatically when all tasks have finished."
        " This flag overrides the corresponding suite config item.",
        action="store_true",
        dest="no_auto_shutdown")

    parser.add_option(
        "--auto-shutdown",
        help="Shut down"
        " the suite automatically when all tasks have finished."
        " This flag overrides the corresponding suite config item.",
        action="store_false",
        dest="no_auto_shutdown")

    parser.add_option("--profile",
                      help="Output profiling (performance) information",
                      action="store_true",
                      dest="profile_mode")

    if is_restart:
        parser.add_option(
            "--checkpoint",
            help="Specify the ID of a checkpoint to restart from",
            metavar="CHECKPOINT-ID",
            action="store",
            dest="checkpoint")

        parser.add_option(
            "--ignore-initial-cycle-point",
            help=(
                "Ignore the initial cycle point in the suite run database. " +
                "If one is specified in the suite definition it will " +
                "be used, however."),
            action="store_true",
            dest="ignore_icp")

        parser.add_option(
            "--ignore-final-cycle-point",
            help=("Ignore the final cycle point in the suite run database. " +
                  "If one is specified in the suite definition it will " +
                  "be used, however."),
            action="store_true",
            dest="ignore_fcp")

        parser.add_option(
            "--ignore-start-cycle-point",
            help="Ignore the start cycle point in the suite run database.",
            action="store_true",
            dest="ignore_startcp")

        parser.add_option(
            "--ignore-stop-cycle-point",
            help="Ignore the stop cycle point in the suite run database.",
            action="store_true",
            dest="ignore_stopcp")

        parser.set_defaults(icp=None,
                            startcp=None,
                            warm=None,
                            ignore_stopcp=None)
    else:
        parser.add_option(
            "-w",
            "--warm",
            help="Warm start the suite. The default is to cold start.",
            action="store_true",
            dest="warm")

        parser.add_option(
            "--start-cycle-point",
            "--start-point",
            help=("Set the start cycle point. Implies --warm."
                  "(Not to be confused with the initial cycle point.)"),
            metavar="CYCLE_POINT",
            action="store",
            dest="startcp")

    parser.add_option("--final-cycle-point",
                      "--final-point",
                      "--until",
                      "--fcp",
                      help="Set the final cycle point.",
                      metavar="CYCLE_POINT",
                      action="store",
                      dest="fcp")

    parser.add_option(
        "--stop-cycle-point",
        "--stop-point",
        help=("Set stop point. "
              "Shut down after all tasks have PASSED this cycle point. "
              "(Not to be confused with the final cycle point.)"
              "Adding this command line option over-rides the workflow"
              "config option [scheduling]stop after cycle point"),
        metavar="CYCLE_POINT",
        action="store",
        dest="stopcp")

    parser.add_option("--hold",
                      help="Hold suite immediately on starting.",
                      action="store_true",
                      dest="hold_start")

    parser.add_option(
        "--hold-point",
        "--hold-after",
        help=("Set hold cycle point. "
              "Hold suite AFTER all tasks have PASSED this cycle point."),
        metavar="CYCLE_POINT",
        action="store",
        dest="holdcp")

    parser.add_option(
        "-m",
        "--mode",
        help="Run mode: live, dummy, dummy-local, simulation (default live).",
        metavar="STRING",
        action="store",
        dest="run_mode",
        choices=["live", "dummy", "dummy-local", "simulation"])

    parser.add_option(
        "--reference-log",
        help="Generate a reference log for use in reference tests.",
        action="store_true",
        default=False,
        dest="genref")

    parser.add_option(
        "--reference-test",
        help="Do a test run against a previously generated reference log.",
        action="store_true",
        default=False,
        dest="reftest")

    # Override standard parser option for specific help description.
    parser.add_option("--host",
                      help=("Specify the host on which to start-up the suite. "
                            "If not specified, a host will be selected using "
                            "the 'suite servers' global config."),
                      metavar="HOST",
                      action="store",
                      dest="host")

    parser.add_option(
        "--format",
        help="The format of the output: 'plain'=human readable, 'json'",
        choices=("plain", "json"),
        default="plain")

    parser.add_option(
        "--main-loop",
        help=("Specify an additional plugin to run in the main loop."
              " These are used in combination with those specified in"
              " [cylc][main loop]plugins. Can be used multiple times"),
        metavar="PLUGIN_NAME",
        action="append",
        dest="main_loop")

    parser.add_option(
        "--abort-if-any-task-fails",
        help="If set workflow will abort with status 1 if any task fails.",
        action="store_true",
        default=False,
        dest="abort_if_any_task_fails")

    parser.set_defaults(stop_point_string=None)
    if add_std_opts:
        # This is for the API wrapper for integration tests. Otherwise (CLI
        # use) "standard options" are added later in options.parse_args().
        # They should really be added in options.__init__() but that requires a
        # bit of refactoring because option clashes are handled bass-ackwards
        # ("overrides" are added before standard options).
        parser.add_std_options()

    return parser