Commit abd8149
fix: Conditionally import required hook
This change makes the library to only import the hook it's going to need
based on the remote scheme.
As it is currently implemented, an environment that uses a S3 remote
fails if it doesn't have the `ssh` Airflow provider installer:
```
Traceback (most recent call last):
File "/usr/local/airflow/.local/lib/python3.10/site-packages/airflow_dbt_python/hooks/dbt.py", line 126, in get_remote
return self.remotes[(scheme, conn_id)]
KeyError: ('s3', None)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/airflow/.local/lib/python3.10/site-packages/airflow_dbt_python/hooks/dbt.py", line 300, in dbt_directory
project_dir, profiles_dir = self.prepare_directory(
File "/usr/local/airflow/.local/lib/python3.10/site-packages/airflow_dbt_python/hooks/dbt.py", line 345, in prepare_directory
project_dir_path = self.download_dbt_project(
File "/usr/local/airflow/.local/lib/python3.10/site-packages/airflow_dbt_python/hooks/dbt.py", line 158, in download_dbt_project
remote = self.get_remote(scheme, self.project_conn_id)
File "/usr/local/airflow/.local/lib/python3.10/site-packages/airflow_dbt_python/hooks/dbt.py", line 128, in get_remote
remote = get_remote(scheme, conn_id)
File "/usr/local/airflow/.local/lib/python3.10/site-packages/airflow_dbt_python/hooks/remote.py", line 147, in get_remote
from .git import DbtGitRemoteHook
File "/usr/local/airflow/.local/lib/python3.10/site-packages/airflow_dbt_python/hooks/git.py", line 5, in <module>
from airflow.providers.ssh.hooks.ssh import SSHHook
ModuleNotFoundError: No module named 'airflow.providers.ssh'
```
The same happens when the environment uses a remote that requires the
SSH hook, and doesn't install the `aws` Airflow provider.1 parent ef1449d commit abd8149
1 file changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | 147 | | |
| 148 | + | |
| 149 | + | |
152 | 150 | | |
153 | 151 | | |
| 152 | + | |
| 153 | + | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
156 | 158 | | |
157 | 159 | | |
158 | 160 | | |
| |||
0 commit comments