def _dir_guildfile(dir, ctx): from guild import guildfile try: return guildfile.from_dir(dir) except guildfile.NoModels: if ctx: help_suffix = " or '%s' for help" % click_util.cmd_help(ctx) else: help_suffix = "" cli.error("%s does not contain a Guild file (guild.yml)\n" "Try specifying a project path or package name%s." % (cwd_desc(dir), help_suffix)) except guildfile.GuildfileError as e: cli.error(str(e))
def _try_guildfile_compare(run): """Returns the current compare for run op if available.""" if run.opref.pkg_type != "guildfile": return None gf_path = run.opref.pkg_name if not os.path.exists(gf_path): return None try: gf = guildfile.from_dir(gf_path) except guildfile.NoModels: return None else: return _try_guildfile_op_compare(gf, run.opref.model_name, run.opref.op_name)
def _init_dist(self): if not os.path.isdir(self.path): return None try: gf = guildfile.from_dir(self.path) except guildfile.NoModels: return None except Exception as e: if log.getEffectiveLevel() <= logging.DEBUG: log.exception(self.path) log.error("error loading guildfile from %s: %s", self.path, e) return BadGuildfileDistribution(self.path) else: return GuildfileDistribution(gf)