diff --git a/airflow_dbt/operators/dbt_operator.py b/airflow_dbt/operators/dbt_operator.py index 8d5e594..77bd1f3 100644 --- a/airflow_dbt/operators/dbt_operator.py +++ b/airflow_dbt/operators/dbt_operator.py @@ -7,6 +7,7 @@ class DbtBaseOperator(BaseOperator): """ Base dbt operator All other dbt operators are derived from this operator. + :param profiles_dir: If set, passed as the `--profiles-dir` argument to the `dbt` command :type profiles_dir: str :param target: If set, passed as the `--target` argument to the `dbt` command @@ -29,8 +30,6 @@ class DbtBaseOperator(BaseOperator): ui_color = '#d6522a' - template_fields = ['vars'] - @apply_defaults def __init__(self, profiles_dir=None, @@ -45,31 +44,16 @@ def __init__(self, *args, **kwargs): super(DbtBaseOperator, self).__init__(*args, **kwargs) - - self.profiles_dir = profiles_dir - self.target = target - self.dir = dir - self.vars = vars - self.models = models - self.full_refresh = full_refresh - self.exclude = exclude - self.dbt_bin = dbt_bin - self.verbose = verbose - self.create_hook() - - def create_hook(self): self.hook = DbtCliHook( - profiles_dir=self.profiles_dir, - target=self.target, - dir=self.dir, - vars=self.vars, - full_refresh=self.full_refresh, - models=self.models, - exclude=self.exclude, - dbt_bin=self.dbt_bin, - verbose=self.verbose) - - return self.hook + profiles_dir=profiles_dir, + target=target, + dir=dir, + vars=vars, + full_refresh=full_refresh, + models=models, + exclude=exclude, + dbt_bin=dbt_bin, + verbose=verbose) class DbtRunOperator(DbtBaseOperator): @@ -78,7 +62,7 @@ def __init__(self, profiles_dir=None, target=None, *args, **kwargs): super(DbtRunOperator, self).__init__(profiles_dir=profiles_dir, target=target, *args, **kwargs) def execute(self, context): - self.create_hook().run_cli('run') + self.hook.run_cli('run') class DbtTestOperator(DbtBaseOperator): @@ -87,4 +71,4 @@ def __init__(self, profiles_dir=None, target=None, *args, **kwargs): super(DbtTestOperator, self).__init__(profiles_dir=profiles_dir, target=target, *args, **kwargs) def execute(self, context): - self.create_hook().run_cli('test') + self.hook.run_cli('test')