Beispiel #1
0
 def f(path):
     if os.path.isfile(path):
         path = os.path.dirname(path)
     cli.note("Running a new shell in %s\n"
              "To exit the shell, type 'exit' and press Enter." % path)
     with util.Chdir(path):
         pty.spawn([shell_cmd])
Beispiel #2
0
def _limit_runs(runs, args):
    if args.all:
        return runs
    limited = runs[:(args.more + 1) * RUNS_PER_GROUP]
    if len(limited) < len(runs):
        cli.note("Showing the first %i runs (%i total) - use --all "
                 "to show all or -m to show more" % (len(limited), len(runs)))
    return limited
Beispiel #3
0
def _op_run_dir_for_args(args):
    if not args.run_dir:
        return None
    run_dir = os.path.abspath(args.run_dir)
    if not args.stage and os.getenv("NO_WARN_RUNDIR") != "1":
        cli.note("Run directory is '%s' (results will not be "
                 "visible to Guild)" % run_dir)
    return run_dir
Beispiel #4
0
def one_run(run_id_prefix, args):
    remote = remote_support.remote_for_args(args)
    cli.note("Getting remote run info")
    try:
        return remote.one_run(run_id_prefix)
    except remotelib.RemoteProcessError as e:
        _handle_remote_process_error(e)
    except remotelib.OperationNotSupported:
        _handle_not_supported(remote)
Beispiel #5
0
def _test_output_scalars(S):
    output_scalars = S.user_op._output_scalars or summary.DEFAULT_OUTPUT_SCALARS
    input_path = S.args.test_output_scalars
    logger = TestOutputLogger()
    if input_path == "-" and sys.stdin.isatty():
        cli.note("Type patterns and press Enter to test. "
                 "Use Ctrl-c or empty line to exit.")
    with _open_output(input_path) as f:
        summary.test_output(f, output_scalars, logger)
Beispiel #6
0
def _list_runs(args, ctx):
    if args.archive and args.deleted:
        cli.error("--archive and --deleted may not both be used")
    runs = filtered_runs(args, ctx=ctx)
    if args.json:
        if args.limit or args.more or args.all:
            cli.note("--json option always shows all runs")
        _list_runs_json(runs)
    else:
        _list_formatted_runs(runs, args)
Beispiel #7
0
def _init_op(opdef, model, args):
    _apply_arg_flags(args, opdef)
    _validate_opdef_flags(opdef)
    _apply_arg_disable_plugins(args, opdef)
    attrs = {"label": args.label} if args.label else None
    if args.run_dir:
        cli.note(
            "Run directory is '%s' (results will not be visible to Guild)" %
            args.run_dir)
    return guild.op.Operation(model, opdef, args.run_dir, attrs)
Beispiel #8
0
def _limit_runs(runs, args):
    if args.all:
        if args.limit is not None:
            cli.error("--all and --limit cannot both be used")
        return runs
    if args.limit and args.limit > 0:
        return runs[:args.limit]
    limited = runs[:(args.more + 1) * RUNS_PER_GROUP]
    if len(limited) < len(runs):
        cli.note("Showing the first %i runs (%i total) - use --all "
                 "to show all or -m to show more" % (len(limited), len(runs)))
    return limited
Beispiel #9
0
def _list_runs(args, ctx):
    if args.archive and not os.path.exists(args.archive):
        cli.error("%s does not exist" % args.archive)
    runs = filtered_runs(args, ctx=ctx)
    if args.comments:
        _list_runs_comments(_limit_runs(runs, args),
                            comment_index_format=False)
    elif args.json:
        if args.limit or args.more or args.all:
            cli.note("--json option always shows all runs")
        _list_runs_json(runs)
    else:
        _list_runs_(_limit_runs(runs, args), args)
Beispiel #10
0
def _op_run_dir(args):
    if args.run_dir:
        run_dir = os.path.abspath(args.run_dir)
        if os.getenv("NO_WARN_RUNDIR") != "1":
            cli.note("Run directory is '%s' (results will not be "
                     "visible to Guild)" % run_dir)
        return run_dir
    elif args.restart:
        assert hasattr(args, "_restart_run")
        return args._restart_run.path
    elif args.stage:
        return os.path.abspath(args.stage)
    else:
        return None
Beispiel #11
0
def filtered_runs_for_pull(remote, args):
    cli.note("Getting remote run info")
    with op_handler(remote):
        return remote.filtered_runs(**_filtered_runs_for_pull_kw(args))
Beispiel #12
0
def _log_flags_info(fmt, *args):
    if os.getenv("FLAGS_TEST") == "1":
        fmt_args = tuple([_fmt_arg(arg) for arg in args])
        cli.note(fmt % fmt_args)
Beispiel #13
0
def _maybe_warn_no_wait(opdef, args):
    if args.no_wait and not (args.remote or opdef.remote):
        cli.note("Operation is local, ignoring --no-wait")