Beispiel #1
0
 def dbt_config(self):
     """Loads the dbt config."""
     if self.dbt_version_tuple >= (1, 0):
         # Here, we read flags.PROFILE_DIR directly, prior to calling
         # set_from_args(). Apparently, set_from_args() sets PROFILES_DIR
         # to a lowercase version of the value, and the profile wouldn't be
         # found if the directory name contained uppercase letters. This fix
         # was suggested and described here:
         # https://github.com/sqlfluff/sqlfluff/issues/2253#issuecomment-1018722979
         user_config = read_user_config(flags.PROFILES_DIR)
         flags.set_from_args(
             DbtConfigArgs(
                 project_dir=self.project_dir,
                 profiles_dir=self.profiles_dir,
                 profile=self._get_profile(),
                 vars=self._get_cli_vars(),
             ),
             user_config,
         )
     self.dbt_config = DbtRuntimeConfig.from_args(
         DbtConfigArgs(
             project_dir=self.project_dir,
             profiles_dir=self.profiles_dir,
             profile=self._get_profile(),
             target=self._get_target(),
             vars=self._get_cli_vars(),
         )
     )
     register_adapter(self.dbt_config)
     return self.dbt_config
Beispiel #2
0
def initialize_config_values(parsed):
    """Given the parsed args, initialize the dbt tracking code.

    It would be nice to re-use this profile later on instead of parsing it
    twice, but dbt's intialization is not structured in a way that makes that
    easy.
    """
    cfg = read_user_config(parsed.profiles_dir)
    cfg.set_values(parsed.profiles_dir)