Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information