Exemplo n.º 1
0
def _ac_runs_for_ctx(ctx):
    from guild import config
    from . import runs_impl

    param_args = click_util.Args(**ctx.params)
    with config.SetGuildHome(ctx.parent.params.get("guild_home")):
        return runs_impl.filtered_runs(param_args, ctx=ctx)
Exemplo n.º 2
0
    def _maybe_restart_rerun_run_dir(self, kw):
        """Return the run dir for a rerun or restart kw.

        If kw contains either a rerun or restart spec, performs a
        lookup within the project Guild home for a single matching run
        and returns its directory.

        This is used to identify the run directory prior to passing
        rerunning/restarting it.
        """
        for name in ("rerun", "restart"):
            spec = kw.get(name)
            if spec:
                from guild import run_util
                from guild.commands import run_impl

                with configlib.SetGuildHome(self.guild_home):
                    run = util.find_apply(
                        [
                            run_util.marked_or_latest_run_for_opspec,
                            run_impl.one_run
                        ],
                        spec,
                    )
                    return run.dir
        return None
Exemplo n.º 3
0
def ac_runs_for_ctx(ctx):
    from guild import config
    from . import runs_impl

    param_args = click_util.Args(**ctx.params)
    if not hasattr(param_args, "runs"):
        param_args.runs = []
    with config.SetGuildHome(ctx.parent.params.get("guild_home")):
        return runs_impl.runs_for_args(param_args, ctx=ctx)
Exemplo n.º 4
0
def _ac_run(incomplete, ctx, **_kw):
    from guild import config
    from guild import var

    with config.SetGuildHome(ctx.parent.params.get("guild_home")):
        runs = var.runs(
            sort=["-timestamp"],
            filter=lambda r: r.id.startswith(incomplete),
        )
    return [run.id for run in runs]
Exemplo n.º 5
0
def completion_safe_apply(ctx, f, args):
    from guild import config

    with config.SetGuildHome(ctx.parent.params.get("guild_home")):
        try:
            return f(*args)
        except (Exception, SystemExit):
            if os.getenv("_GUILD_COMPLETE_DEBUG") == "1":
                raise
            return None
Exemplo n.º 6
0
def runs_for_ctx(ctx):
    from guild import config
    from . import runs_impl

    args = _runs_args_for_ctx(ctx)
    with config.SetGuildHome(ctx.parent.params.get("guild_home")):
        try:
            return runs_impl.runs_for_args(args, ctx=ctx)
        except SystemExit:
            # Raised when cannot find runs for args.
            return []
Exemplo n.º 7
0
def get_training_runs(operation_name,
                      guild_env_path=get_current_guild_env_path()):
    """
    get guild runs with specified operation_name
    by default it will use guild from current environment
    """
    guild_home = cfg.SetGuildHome(guild_env_path)
    with guild_home:
        runs_df = guild.runs()
    training_runs_df = runs_df[runs_df["operation"] == operation_name]
    training_runs_df.loc[:, "run"] = training_runs_df["run"][:].apply(str)
    return training_runs_df
Exemplo n.º 8
0
def get_weight_files(run_id, guild_env_path=get_current_guild_env_path()):
    """
    get Keras model weight files for specified run_id
    """
    if run_id is None:
        return os.listdir()
    else:
        guild_home = cfg.SetGuildHome(guild_env_path)
        all_run_dirs = os.listdir("/".join([guild_env_path, "runs"]))
        runs_df = get_training_runs(guild_home)
        run_path = [
            os.path.join(guild_env_path, "runs", p) for p in all_run_dirs
            if p.startswith(run_id)
        ][0]
        return sorted(glob.glob("/".join([run_path, "*weight*"])))
Exemplo n.º 9
0
    def __init__(self, cwd, guild_home=None):
        from guild import config

        guild_home = guild_home or config.guild_home()
        self._set_cwd = config.SetCwd(cwd or ".")
        self._set_guild_home = config.SetGuildHome(guild_home)