Ejemplo n.º 1
0
def runs_list_options(fn):
    click_util.append_params(fn, [
        runs_support.all_filters,
        click.Option(
            ("-d", "--deleted"), help="Show deleted runs.", is_flag=True),
        click.Option((
            "-A",
            "--archive",
        ),
                     metavar="DIR",
                     help="Show archived runs in DIR."),
        click.Option(
            ("-a", "--all"),
            help="Show all runs (by default only the last 20 runs are shown).",
            is_flag=True),
        click.Option(("-m", "--more"),
                     help=("Show 20 more runs. Maybe used multiple times."),
                     count=True),
        click.Option(("--json", ), help="Format runs as JSON.", is_flag=True),
        click.Option(
            ("-v", "--verbose"), help="Show run details.", is_flag=True),
        click.Option((
            "-r",
            "--remote",
        ),
                     metavar="REMOTE",
                     help="List runs on REMOTE rather than local runs."),
    ])
    return fn
Ejemplo n.º 2
0
def runs_op(fn):
    click_util.append_params(fn, [
        runs_arg,
        op_and_label_filters,
        status_filters,
    ])
    return fn
Ejemplo n.º 3
0
def export_params(fn):
    click_util.append_params(
        fn,
        [
            runs_support.runs_arg,
            click.Argument(("location", )),
            click.Option(
                ("-m", "--move"),
                help="Move exported runs rather than copy.",
                is_flag=True,
            ),
            click.Option(
                ("-r", "--copy-resources"),
                help="Copy resources for each exported run.",
                is_flag=True,
            ),
            runs_support.all_filters,
            click.Option(("-y", "--yes"),
                         help="Do not prompt before exporting.",
                         is_flag=True),
        ],
    )
    assert fn.__click_params__[-1].name == "runs", fn.__click_params__
    fn.__click_params__[-1].autocompletion = _ac_location
    return fn
Ejemplo n.º 4
0
def status_filters(fn):
    """### Filtering by run status

    Runs may also be filtered by specifying one or more status
    filters: `--running`, `--completed`, `--error`, and
    `--terminated`. These may be used together to include runs that
    match any of the filters. For example to only include runs that
    were either terminated or exited with an error, use ``--terminated
    --error``, or the short form ``-ET``.

    Status filters are applied before `RUN` indexes are resolved. For
    example, a run index of ``1`` is the latest run that matches the
    status filters.

    """
    click_util.append_params(fn, [
        click.Option(("-R", "--running"),
                     help="Include only runs that are still running.",
                     is_flag=True),
        click.Option(("-C", "--completed"),
                     help="Include only completed runs.",
                     is_flag=True),
        click.Option(("-E", "--error"),
                     help="Include only runs that exited with an error.",
                     is_flag=True),
        click.Option(("-T", "--terminated"),
                     help="Include only runs terminated by the user.",
                     is_flag=True),
        click.Option(("-P", "--pending"),
                     help="Include only pending runs.",
                     is_flag=True),
    ])
    return fn
Ejemplo n.º 5
0
def run_params(fn):
    click_util.append_params(fn, [
        click.Argument(("args", ), metavar="[ARG...]", nargs=-1),
        click.Option(
            ("-p", "--project", "project_location"),
            metavar="LOCATION",
            help="Project location (file system directory) for MODEL."),
        click.Option(
            ("--disable-plugins", ),
            metavar="LIST",
            help=("A comma separated list of plugin names to disable. "
                  "Use 'all' to disable all plugins.")),
        click.Option(("-y", "--yes"),
                     help="Do not prompt before running operation.",
                     is_flag=True),
        click.Option(
            ("--print-cmd", ),
            help="Show the operation command and exit (does not run).",
            is_flag=True),
        click.Option(
            ("--print-env", ),
            help="Show the operation environment and exit (does not run).",
            is_flag=True),
    ])
    return fn
Ejemplo n.º 6
0
def diff_params(fn):
    click_util.append_params(fn, [
        click.Argument(("runs", ), metavar="[RUN1 RUN2]", nargs=-1),
        click.Option(
            ("-O", "--output"), is_flag=True, help="Diff run output."),
        click.Option(
            ("-s", "--source"), is_flag=True, help="Diff run source."),
        click.Option(
            ("-e", "--env"), is_flag=True, help="Diff run environment."),
        click.Option(("-g", "--flags"), is_flag=True, help="Diff run flags."),
        click.Option(("-a", "--attrs"),
                     is_flag=True,
                     help=("Diff all run attributes; if specified other "
                           "attribute options are ignored.")),
        click.Option(
            ("-d", "--deps"), is_flag=True, help="Diff run dependencies."),
        click.Option(("-p", "--path"),
                     metavar="PATH",
                     multiple=True,
                     help="Diff specified path; may be used more than once."),
        click.Option(
            ("-c", "--cmd"), metavar="CMD", help="Command used to diff runs."),
        runs_support.op_and_label_filters,
        runs_support.status_filters,
    ])
    return fn
Ejemplo n.º 7
0
def diff_params(fn):
    click_util.append_params(fn, [
        click.Argument(("runs", ), metavar="[RUN1 [RUN2]]", nargs=-1),
        click.Option(
            ("-O", "--output"), is_flag=True, help="Diff run output."),
        click.Option(
            ("-c", "--sourcecode"), is_flag=True,
            help="Diff run source code."),
        click.Option(
            ("-e", "--env"), is_flag=True, help="Diff run environment."),
        click.Option(("-g", "--flags"), is_flag=True, help="Diff run flags."),
        click.Option(("-a", "--attrs"),
                     is_flag=True,
                     help=("Diff all run attributes; if specified other "
                           "attribute options are ignored.")),
        click.Option(
            ("-d", "--deps"), is_flag=True, help="Diff run dependencies."),
        click.Option(("-p", "--path"),
                     metavar="PATH",
                     multiple=True,
                     help="Diff specified path; may be used more than once."),
        click.Option(
            ("-w", "--working"),
            is_flag=True,
            help="Diff run sourcecode to the associated working directory."),
        click.Option(("-W", "--working-dir"),
                     metavar="PATH",
                     help="Diff run sourcecode to the specified directory."),
        click.Option(
            ("-m", "--cmd"), metavar="CMD", help="Command used to diff runs."),
        runs_support.all_filters,
        remote_support.remote_option("Diff remote runs."),
    ])
    return fn
Ejemplo n.º 8
0
def runs_arg(fn):
    """### Specify Runs

    You may use one or more `RUN` arguments to indicate which runs
    apply to the command. `RUN` may be a run ID, a run ID prefix, or a
    one-based index corresponding to a run returned by the list
    command.

    Indexes may also be specified in ranges in the form `START:END`
    where `START` is the start index and `END` is the end
    index. Either `START` or `END` may be omitted. If `START` is
    omitted, all runs up to `END` are selected. If `END` id omitted,
    all runs from `START` on are selected. If both `START` and `END`
    are omitted (i.e. the ``:`` char is used by itself) all runs are
    selected.

    """
    click_util.append_params(
        fn,
        [
            click.Argument(
                ("runs",), metavar="[RUN...]", nargs=-1, autocompletion=ac_run
            )
        ],
    )
    return fn
Ejemplo n.º 9
0
def label_params(fn):
    click_util.append_params(
        fn,
        [
            runs_support.runs_arg,
            click.Option(("-s", "--set"), metavar="VAL", help="Set VAL as label."),
            click.Option(
                ("-p", "-t", "--prepend", "--tag"),
                metavar="VAL",
                help="Prepend VAL to existing label.",
            ),
            click.Option(
                ("-a", "--append"), metavar="VAL", help="Append VAL to existing label."
            ),
            click.Option(
                ("-rm", "-u", "--remove", "--untag"),
                metavar="VAL",
                multiple=True,
                help="Remove VAL from existing label. May be used multiple times.",
            ),
            click.Option(
                ("-c", "--clear"), help="Clear the entire run label.", is_flag=True
            ),
            runs_support.all_filters,
            remote_support.remote_option("Label remote runs."),
            click.Option(
                ("-y", "--yes"),
                help="Do not prompt before modifying labels.",
                is_flag=True,
            ),
        ],
    )
    return fn
Ejemplo n.º 10
0
def run_params(fn):
    click_util.append_params(fn, [
        click.Argument(("args",), metavar="[ARG...]", nargs=-1),
        click.Option(
            ("-l", "--label"), metavar="LABEL",
            help="Set a label for the run."),
        click.Option(
            ("-d", "--run-dir"), metavar="DIR",
            help="Use an alternative run directory."),
        click.Option(
            ("--disable-plugins",), metavar="LIST",
            help=("A comma separated list of plugin names to disable. "
                  "Use 'all' to disable all plugins.")),
        click.Option(
            ("-y", "--yes"),
            help="Do not prompt before running operation.",
            is_flag=True),
        click.Option(
            ("--print-command",),
            help="Show the operation command and exit (does not run).",
            is_flag=True),
        click.Option(
            ("--print-env",),
            help="Show the operation environment and exit (does not run).",
            is_flag=True),
    ])
    return fn
Ejemplo n.º 11
0
def publish_params(fn):
    click_util.append_params(fn, [
        runs_support.runs_arg,
        click.Option(("-d", "--dest"),
                     metavar="DIR",
                     help="Destination to publish runs."),
        click.Option(("-t", "--template"),
                     metavar="VAL",
                     help="Template used to publish runs."),
        click.Option(
            ("-f", "--files"), help="Publish default run files.",
            is_flag=True),
        click.Option(
            ("-a", "--all-files"), help="Publish all run files.",
            is_flag=True),
        click.Option(
            ("-L", "--include-links"),
            help="Include links when publishing files. Implies --files.",
            is_flag=True),
        click.Option(("--no-md5", ),
                     help="Do not calculate MD5 digests for run files.",
                     is_flag=True),
        click.Option(
            ("--include-batch", ), help="Include batch runs.", is_flag=True),
        click.Option(("-r", "--refresh-index"),
                     help="Refresh runs index without publishing anything.",
                     is_flag=True),
        runs_support.op_and_label_filters,
        runs_support.status_filters,
        click.Option(("-y", "--yes"),
                     help="Do not prompt before publishing.",
                     is_flag=True),
    ])
    return fn
Ejemplo n.º 12
0
def time_filters(fn):
    """### Filter by Run Start Time

    Use `--started` to limit runs to those that have started within a
    specified time range.

    **IMPORTANT:** You must quote RANGE values that contain
    spaces. For example, to filter runs started within the last hour,
    use the option:

        --selected 'last hour'

    You can specify a time range using several different forms:

      \b
      `after DATETIME`
      `before DATETIME`
      `between DATETIME and DATETIME`
      `last N minutes|hours|days`
      `today|yesterday`
      `this week|month|year`
      `last week|month|year`
      `N days|weeks|months|years ago`

    `DATETIME` may be specified as a date in the format ``YY-MM-DD``
    (the leading ``YY-`` may be omitted) or as a time in the format
    ``HH:MM`` (24 hour clock). A date and time may be specified
    together as `DATE TIME`.

    When using ``between DATETIME and DATETIME``, values for
    `DATETIME` may be specified in either order.

    When specifying values like ``minutes`` and ``hours`` the training
    ``s`` may be omitted to improve readability. You may also use
    ``min`` instead of ``minutes`` and ``hr`` instead of ``hours``.

    Examples:

      \b
      `after 7-1`
      `after 9:00`
      `between 1-1 and 4-30`
      `between 10:00 and 15:00`
      `last 30 min`
      `last 6 hours`
      `today`
      `this week`
      `last month`
      `3 weeks ago`

    """
    click_util.append_params(fn, [
        click.Option(
            ("-s", "--started",),
            metavar="RANGE",
            help=(
                "Include only runs started within RANGE. See above "
                "for valid time ranges."))
    ])
    return fn
Ejemplo n.º 13
0
def run_filters(fn):
    click_util.append_params(fn, [
        click.Option(("-m", "--model", "models"),
                     metavar="MODEL",
                     help="Include only runs for MODEL.",
                     multiple=True),
        click.Option(("-R", "--running", "status"),
                     help="Include only runs that are still running.",
                     flag_value="running"),
        click.Option(("-C", "--completed", "status"),
                     help="Include only completed runs.",
                     flag_value="completed"),
        click.Option(
            ("-S", "--stopped", "status"),
            help=("Include only runs that exited with an error or were "
                  "terminated by the user."),
            flag_value="stopped"),
        click.Option(("-E", "--error", "status"),
                     help="Include only runs that exited with an error.",
                     flag_value="error"),
        click.Option(("-T", "--terminated", "status"),
                     help="Include only runs terminated by the user.",
                     flag_value="terminated"),
    ])
    return fn
Ejemplo n.º 14
0
def op_and_label_filters(fn):
    """### Filter by Operation or Label

    Runs may be filtered by operation using `--operation`.  A run is
    only included if any part of its full operation name, including
    the package and model name, matches the value.

    Use `--label` to only include runs with labels matching a
    specified value.

    `--operation` and `--label` may be used multiple times to expand
    the runs that are included.

    Use `--unlabeled` to only include runs without labels. This option
    may not be used with `--label`.

    Use `--marked` to only include marked runs.

    """
    click_util.append_params(
        fn,
        [
            click.Option(
                ("-o", "--operation", "ops"),
                metavar="VAL",
                help="Include runs with operations matching `VAL`.",
                multiple=True,
            ),
            click.Option(
                ("-l", "--label", "labels"),
                metavar="VAL",
                help="Include runs with labels matching `VAL`.",
                multiple=True,
            ),
            click.Option(
                (
                    "-u",
                    "--unlabeled",
                ),
                help="Include only runs without labels.",
                is_flag=True,
            ),
            click.Option((
                "-M",
                "--marked",
            ),
                         help="Include only marked runs.",
                         is_flag=True),
            click.Option((
                "-U",
                "--unmarked",
            ),
                         help="Include only unmarked runs.",
                         is_flag=True),
        ],
    )
    return fn
Ejemplo n.º 15
0
def comment_params(fn):
    click_util.append_params(
        fn,
        [
            runs_support.runs_arg,
            click.Option(
                ("-l", "--list"),
                help="List comments for specified runs.",
                is_flag=True,
            ),
            click.Option(
                ("-a", "--add"),
                metavar="COMMENT",
                help="Add comment to specified runs.",
            ),
            click.Option(
                ("-e", "--edit"),
                help=(
                    "Use an editor to type a comment. Enabled by default if "
                    "COMMENT is not specified using --add."
                ),
                is_flag=True,
            ),
            click.Option(
                ("-d", "--delete"),
                metavar="INDEX",
                help=(
                    "Delete comment at INDEX from specified runs. Use `--list` "
                    "to show available indexes."
                ),
                type=click.INT,
                autocompletion=_ac_comment_index,
            ),
            click.Option(
                ("-c", "--clear"),
                help="Clear all comments associated with specified runs.",
                is_flag=True,
            ),
            click.Option(
                ("-u", "--user"),
                metavar="USER",
                help=(
                    "User associated with new comments. May include host "
                    "as USER@HOST. By default the current user is used."
                ),
            ),
            runs_support.all_filters,
            remote_support.remote_option("Apply comments to remote runs."),
            click.Option(
                ("-y", "--yes"),
                help="Do not prompt before modifying comments.",
                is_flag=True,
            ),
        ],
    )
    runs_support.acquire_deprecated_option(fn, "-l", "list")
    return fn
Ejemplo n.º 16
0
def run_arg(fn):
    """### Specify a Run

    You may specify a run using a run ID, a run ID prefix, or a
    one-based index corresponding to a run returned by the list
    command.

    """
    click_util.append_params(fn, [click.Argument(("run", ), required=False)])
    return fn
Ejemplo n.º 17
0
def runs_list_options(fn):
    run_scope_options(fn)
    run_filters(fn)
    click_util.append_params(fn, [
        click.Option(
            ("-v", "--verbose"), help="Show run details.", is_flag=True),
        click.Option(
            ("-d", "--deleted"), help="Show deleted runs.", is_flag=True),
    ])
    return fn
Ejemplo n.º 18
0
def remote_arg(fn):
    """`REMOTE` is the name of a configured remote. Use ``guild remotes``
    to list available remotes.

    For information on configuring remotes, see ``guild remotes
    --help``.

    """
    click_util.append_params(fn, [click.Argument(("remote", ))])
    return fn
Ejemplo n.º 19
0
def delete_params(fn):
    click_util.append_params(fn, [
        click.Argument(
            ("packages",), metavar="PACKAGE...",
            nargs=-1, required=True),
        click.Option(
            ("-y", "--yes",),
            help="Do not prompt before uninstalling.",
            is_flag=True),
    ])
    return fn
Ejemplo n.º 20
0
def mark_params(fn):
    click_util.append_params(fn, [
        runs_support.runs_arg,
        runs_support.all_filters,
        click.Option(("-c", "--clear"),
                     help="Clear the run's selected designation.",
                     is_flag=True),
        click.Option(("-y", "--yes"),
                     help="Do not prompt before modifying runs.",
                     is_flag=True),
    ])
    return fn
Ejemplo n.º 21
0
def all_filters(fn):
    """
    {{ op_and_label_filters }}
    {{ status_filters }}
    {{ time_filters }}
    """
    click_util.append_params(fn, [
        op_and_label_filters,
        status_filters,
        time_filters,
    ])
    return fn
Ejemplo n.º 22
0
 def wrapper(fn):
     click_util.append_params(
         fn,
         [
             click.Option(
                 ("-r", "--remote"),
                 metavar="REMOTE",
                 help=help,
                 autocompletion=_ac_remote,
             )
         ],
     )
     return fn
Ejemplo n.º 23
0
def label_params(fn):
    click_util.append_params(fn, [
        runs_support.runs_arg,
        click.Argument(("label", ), required=False),
        runs_support.all_filters,
        click.Option(
            ("-c", "--clear"), help="Clear the run's label.", is_flag=True),
        remote_support.remote_option("Label remote runs."),
        click.Option(("-y", "--yes"),
                     help="Do not prompt before modifying labels.",
                     is_flag=True),
    ])
    return fn
Ejemplo n.º 24
0
 def wrapper(fn):
     click_util.append_params(
         fn,
         [
             click.Option(
                 ("-A", "--archive"),
                 metavar="PATH",
                 help=help,
                 autocompletion=ac_archive,
             )
         ],
     )
     return fn
Ejemplo n.º 25
0
def all_filters(fn):
    """
    {{ common_filters }}
    {{ status_filters }}
    """
    click_util.append_params(
        fn,
        [
            common_filters,
            status_filters,
        ],
    )
    return fn
Ejemplo n.º 26
0
def runs_stop_params(fn):
    click_util.append_params(fn, [
        runs_support.runs_arg,
        runs_support.op_and_label_filters,
        remote_support.remote_option("Stop remote runs."),
        click.Option(("-y", "--yes"),
                     help="Do not prompt before stopping.",
                     is_flag=True),
        click.Option(("-n", "--no-wait"),
                     help="Don't wait for remote runs to stop.",
                     is_flag=True),
    ])
    return fn
Ejemplo n.º 27
0
def run_scope_options(fn):
    click_util.append_params(fn, [
        click.Option(
            ("-p", "--project", "project_location"), metavar="LOCATION",
            help=("Project location (file system directory) for filtering "
                  "runs.")),
        click.Option(
            ("-S", "--system"),
            help=("Include system wide runs rather than limit to runs "
                  "associated with a project location. Ignores LOCATION."),
            is_flag=True)
    ])
    return fn
Ejemplo n.º 28
0
def push_params(fn):
    click_util.append_params(fn, [
        remote_support.remote_arg,
        runs_support.runs_arg,
        runs_support.op_and_label_filters,
        runs_support.status_filters,
        click.Option(
            ("-n", "--delete",),
            help="Delete remote files missing locally.",
            is_flag=True),
        click.Option(
            ("-y", "--yes"),
            help="Do not prompt before copying.",
            is_flag=True),
    ])
    return fn
Ejemplo n.º 29
0
def pull_params(fn):
    click_util.append_params(fn, [
        click.Argument(("runs",), metavar="[RUN...]", nargs=-1),
        remote_support.remote_arg,
        runs_support.op_and_label_filters,
        runs_support.status_filters,
        click.Option(
            ("-d", "--delete",),
            help="Delete local files missing on remote.",
            is_flag=True),
        click.Option(
            ("-y", "--yes"),
            help="Do not prompt before copying.",
            is_flag=True),
    ])
    return fn
Ejemplo n.º 30
0
def pull_params(fn):
    click_util.append_params(fn, [
        remote_support.remote_arg,
        runs_support.runs_arg,
        runs_support.all_filters,
        click.Option((
            "-d",
            "--delete",
        ),
                     help="Delete local files missing on remote.",
                     is_flag=True),
        click.Option(("-y", "--yes"),
                     help="Do not prompt before copying.",
                     is_flag=True),
    ])
    return fn