Skip to content

Commit eb111bc

Browse files
millintomasfarias
authored andcommitted
fix: rename remote to fs
1 parent 7b2daac commit eb111bc

24 files changed

+167
-167
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"""Hooks module provides DbtHooks and DbtRemoteHooks."""
1+
"""Hooks module provides DbtHooks and DbtFSHooks."""

airflow_dbt_python/hooks/dbt.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
if TYPE_CHECKING:
3434
from dbt.contracts.results import RunResult
3535

36-
from airflow_dbt_python.hooks.remote import DbtRemoteHook
36+
from airflow_dbt_python.hooks.fs import DbtFSHook
3737
from airflow_dbt_python.hooks.target import DbtConnectionHook
3838
from airflow_dbt_python.utils.configs import BaseConfig
3939
from airflow_dbt_python.utils.url import URLLike
4040

41-
DbtRemoteHooksDict = Dict[Tuple[str, Optional[str]], DbtRemoteHook]
41+
DbtFSHooksDict = Dict[Tuple[str, Optional[str]], DbtFSHook]
4242

4343

4444
class DbtTaskResult(NamedTuple):
@@ -103,16 +103,16 @@ def get_dbt_target_hook(conn_id: str) -> DbtConnectionHook:
103103
return DbtConnectionHook.get_db_conn_hook(conn_id)
104104

105105
@staticmethod
106-
def get_remote(scheme: str, conn_id: Optional[str]) -> DbtRemoteHook:
107-
"""Get a remote to interact with dbt files.
106+
def get_fs_hook(scheme: str, conn_id: Optional[str]) -> DbtFSHook:
107+
"""Get a fs_hook to interact with dbt files.
108108
109-
RemoteHooks are defined by the scheme we are looking for and an optional
109+
FSHooks are defined by the scheme we are looking for and an optional
110110
connection id if we are looking to interface with any Airflow hook that
111111
uses a connection.
112112
"""
113-
from .remote import get_remote
113+
from .fs import get_fs_hook
114114

115-
return get_remote(scheme, conn_id)
115+
return get_fs_hook(scheme, conn_id)
116116

117117
def download_dbt_profiles(
118118
self,
@@ -121,13 +121,13 @@ def download_dbt_profiles(
121121
) -> Path:
122122
"""Pull a dbt profiles.yml file from a given profiles_dir.
123123
124-
This operation is delegated to a DbtRemoteHook. An optional connection id is
124+
This operation is delegated to a DbtFSHook. An optional connection id is
125125
supported for remotes that require it.
126126
"""
127127
scheme = urlparse(str(profiles_dir)).scheme
128-
remote = self.get_remote(scheme, self.profiles_conn_id)
128+
fs_hook = self.get_fs_hook(scheme, self.profiles_conn_id)
129129

130-
return remote.download_dbt_profiles(profiles_dir, destination)
130+
return fs_hook.download_dbt_profiles(profiles_dir, destination)
131131

132132
def download_dbt_project(
133133
self,
@@ -136,13 +136,13 @@ def download_dbt_project(
136136
) -> Path:
137137
"""Pull a dbt project from a given project_dir.
138138
139-
This operation is delegated to a DbtRemoteHook. An optional connection id is
139+
This operation is delegated to a DbtFSHook. An optional connection id is
140140
supported for remotes that require it.
141141
"""
142142
scheme = urlparse(str(project_dir)).scheme
143-
remote = self.get_remote(scheme, self.project_conn_id)
143+
fs_hook = self.get_fs_hook(scheme, self.project_conn_id)
144144

145-
return remote.download_dbt_project(project_dir, destination)
145+
return fs_hook.download_dbt_project(project_dir, destination)
146146

147147
def upload_dbt_project(
148148
self,
@@ -153,13 +153,13 @@ def upload_dbt_project(
153153
) -> None:
154154
"""Push a dbt project from a given project_dir.
155155
156-
This operation is delegated to a DbtRemoteHook. An optional connection id is
156+
This operation is delegated to a DbtFSHook. An optional connection id is
157157
supported for remotes that require it.
158158
"""
159159
scheme = urlparse(str(destination)).scheme
160-
remote = self.get_remote(scheme, self.project_conn_id)
160+
fs_hook = self.get_fs_hook(scheme, self.project_conn_id)
161161

162-
return remote.upload_dbt_project(
162+
return fs_hook.upload_dbt_project(
163163
project_dir, destination, replace=replace, delete_before=delete_before
164164
)
165165

airflow_dbt_python/hooks/remote/__init__.py renamed to airflow_dbt_python/hooks/fs/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
"""The DbtRemoteHook interface includes methods for downloading and uploading files.
1+
"""The DbtFSHook interface includes methods for downloading and uploading files.
22
3-
Internally, DbtRemoteHooks can use Airflow hooks to execute the actual operations.
3+
Internally, DbtFSHooks can use Airflow hooks to execute the actual operations.
44
55
Currently, only AWS S3 and the local filesystem are supported as remotes.
66
"""
@@ -17,7 +17,7 @@
1717
StrPath = str
1818

1919

20-
class DbtRemoteHook(ABC, LoggingMixin):
20+
class DbtFSHook(ABC, LoggingMixin):
2121
"""Represents a dbt project storing any dbt files.
2222
2323
A concrete backend class should implement the push and pull methods to fetch one
@@ -141,33 +141,33 @@ def upload_dbt_project(
141141

142142

143143
@cache
144-
def get_remote(scheme: str, conn_id: Optional[str] = None) -> DbtRemoteHook:
145-
"""Get a DbtRemoteHook as long as the scheme is supported.
144+
def get_fs_hook(scheme: str, conn_id: Optional[str] = None) -> DbtFSHook:
145+
"""Get a DbtFSHook as long as the scheme is supported.
146146
147147
In the future we should make our hooks discoverable and package ourselves as a
148148
proper Airflow providers package.
149149
"""
150150
if scheme == "s3":
151-
from .s3 import DbtS3RemoteHook
151+
from .s3 import DbtS3FSHook
152152

153-
remote_cls: Type[DbtRemoteHook] = DbtS3RemoteHook
153+
fs_hook_cls: Type[DbtFSHook] = DbtS3FSHook
154154
elif scheme == "gs":
155-
from .gcs import DbtGCSRemoteHook
155+
from .gcs import DbtGCSFSHook
156156

157-
remote_cls = DbtGCSRemoteHook
157+
fs_hook_cls = DbtGCSFSHook
158158
elif scheme in ("https", "git", "git+ssh", "ssh", "http"):
159-
from .git import DbtGitRemoteHook
159+
from .git import DbtGitFSHook
160160

161-
remote_cls = DbtGitRemoteHook
161+
fs_hook_cls = DbtGitFSHook
162162
elif scheme == "":
163-
from .localfs import DbtLocalFsRemoteHook
163+
from .local import DbtLocalFsHook
164164

165-
remote_cls = DbtLocalFsRemoteHook
165+
fs_hook_cls = DbtLocalFsHook
166166
else:
167167
raise NotImplementedError(f"Backend {scheme} is not supported")
168168

169169
if conn_id is not None:
170-
remote = remote_cls(conn_id)
170+
fs_hook = fs_hook_cls(conn_id)
171171
else:
172-
remote = remote_cls()
173-
return remote
172+
fs_hook = fs_hook_cls()
173+
return fs_hook
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
from airflow.providers.google.cloud.hooks.gcs import GCSHook, _parse_gcs_url
1010
from google.cloud.storage import Blob
1111

12-
from airflow_dbt_python.hooks.remote import DbtRemoteHook
12+
from airflow_dbt_python.hooks.fs import DbtFSHook
1313
from airflow_dbt_python.utils.url import URL, URLLike
1414

1515

16-
class DbtGCSRemoteHook(GCSHook, DbtRemoteHook):
16+
class DbtGCSFSHook(GCSHook, DbtFSHook):
1717
"""A dbt remote implementation for GCS.
1818
19-
This concrete remote class implements the DbtRemote interface by using GCS as a
19+
This concrete remote class implements the DbtFs interface by using GCS as a
2020
storage for uploading and downloading dbt files to and from.
21-
The DbtGCSRemoteHook subclasses Airflow's GCSHook to interact with GCS.
21+
The DbtGCSFSHook subclasses Airflow's GCSHook to interact with GCS.
2222
A connection id may be passed to set the connection to use with GCS.
2323
"""
2424

@@ -128,7 +128,7 @@ def _download(
128128
destination: A destination URL where to download the objects to. The
129129
existing sub-directory hierarchy in GCS will be preserved.
130130
replace: Indicates whether to replace existing files when downloading.
131-
This flag is kept here to comply with the DbtRemote interface but its
131+
This flag is kept here to comply with the DbtFs interface but its
132132
ignored as files downloaded from GCS always overwrite local files.
133133
delete_before: Delete destination directory before download.
134134
"""
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""A concrete DbtRemoteHook for git repositories with dulwich."""
1+
"""A concrete DbtFSHook for git repositories with dulwich."""
22

33
import datetime as dt
44
from typing import Callable, Optional, Tuple, Union
@@ -11,7 +11,7 @@
1111
from dulwich.protocol import ZERO_SHA
1212
from dulwich.repo import Repo
1313

14-
from airflow_dbt_python.hooks.remote import DbtRemoteHook
14+
from airflow_dbt_python.hooks.fs import DbtFSHook
1515
from airflow_dbt_python.utils.url import URL
1616

1717
GitClients = Union[HttpGitClient, SSHGitClient, TCPGitClient]
@@ -22,13 +22,13 @@ def no_filter(_: URL) -> bool:
2222
return True
2323

2424

25-
class DbtGitRemoteHook(SSHHook, DbtRemoteHook):
25+
class DbtGitFSHook(SSHHook, DbtFSHook):
2626
"""A dbt remote implementation for git repositories.
2727
28-
This concrete remote class implements the DbtRemote interface by using any git
28+
This concrete remote class implements the DbtFs interface by using any git
2929
repository to upload and download dbt files to and from.
3030
31-
The DbtGitRemoteHook subclasses Airflow's SSHHook to interact with to utilize its
31+
The DbtGitFSHook subclasses Airflow's SSHHook to interact with to utilize its
3232
defined methods to operate with SSH connections. However, SSH connections are not
3333
the only ones supported for interacting with git repositories: HTTP (http:// or
3434
https://) and plain TCP (git://) may be used.

airflow_dbt_python/hooks/remote/localfs.py renamed to airflow_dbt_python/hooks/fs/local.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
from airflow.hooks.filesystem import FSHook
1414

15-
from airflow_dbt_python.hooks.remote import DbtRemoteHook
15+
from airflow_dbt_python.hooks.fs import DbtFSHook
1616
from airflow_dbt_python.utils.url import URL
1717

1818

19-
class DbtLocalFsRemoteHook(FSHook, DbtRemoteHook):
20-
"""A concrete dbt remote for a local filesystem.
19+
class DbtLocalFsHook(FSHook, DbtFSHook):
20+
"""A concrete dbt hook for a local filesystem.
2121
22-
This remote is intended to be used when running Airflow with a LocalExecutor, and
22+
This hook is intended to be used when running Airflow with a LocalExecutor, and
2323
it relies on shutil from the standard library to do all the file manipulation. For
2424
these reasons, running multiple concurrent tasks with this remote may lead to race
2525
conditions if attempting to push files to the remote.
@@ -28,7 +28,7 @@ class DbtLocalFsRemoteHook(FSHook, DbtRemoteHook):
2828
conn_name_attr = "fs_conn_id"
2929
default_conn_name = "fs_default"
3030
conn_type = "filesystem"
31-
hook_name = "dbt Local Filesystem RemoteHook"
31+
hook_name = "dbt Local Filesystem FSHook"
3232

3333
def __init__(
3434
self,
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
from airflow.providers.amazon.aws.hooks.s3 import S3Hook
88

9-
from airflow_dbt_python.hooks.remote import DbtRemoteHook
9+
from airflow_dbt_python.hooks.fs import DbtFSHook
1010
from airflow_dbt_python.utils.url import URL, URLLike
1111

1212

13-
class DbtS3RemoteHook(S3Hook, DbtRemoteHook):
13+
class DbtS3FSHook(S3Hook, DbtFSHook):
1414
"""A dbt remote implementation for S3.
1515
16-
This concrete remote class implements the DbtRemote interface by using S3 as a
16+
This concrete remote class implements the DbtFs interface by using S3 as a
1717
storage for uploading and downloading dbt files to and from.
18-
The DbtS3RemoteHook subclasses Airflow's S3Hook to interact with S3. A connection id
18+
The DbtS3FSHook subclasses Airflow's S3Hook to interact with S3. A connection id
1919
may be passed to set the connection to use with S3.
2020
"""
2121

@@ -126,7 +126,7 @@ def _download(
126126
destination: A destination URL where to download the objects to. The
127127
existing sub-directory hierarchy in S3 will be preserved.
128128
replace: Indicates whether to replace existing files when downloading.
129-
This flag is kept here to comply with the DbtRemote interface but its
129+
This flag is kept here to comply with the DbtFs interface but its
130130
ignored as files downloaded from S3 always overwrite local files.
131131
delete_before: Delete destination directory before download.
132132
"""

docs/getting_started.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ When Airflow is installed is running on a multi- machine or cloud installation,
229229

230230
For these deployments we must rely on a *dbt* remote to download and, eventually, upload all required *dbt* files. The remote *dbt* URL may be used in place of a local ``project_dir`` or ``profiles_dir`` to have *airflow-dbt-python* download the *dbt* files in the remote into a temporary directory for execution.
231231

232-
Interactions with storages are supported by subclasses of ``DbtRemoteHook``. Read the documentation :ref:`dbt_remote_hooks` to learn more about these hooks.
232+
Interactions with storages are supported by subclasses of ``DbtFSHook``. Read the documentation :ref:`dbt_remote_hooks` to learn more about these hooks.
233233

234234
As an example, let's upload our *dbt* project to an AWS S3 bucket. The files may end up structured in the bucket as:
235235

@@ -285,7 +285,7 @@ Then, we can alter the previous example DAG to set ``project_dir`` and ``profile
285285
profile="my-project",
286286
)
287287
288-
*airflow-dbt-python* uses the URL scheme (in this example, ``"s3"``) to figure out the type of remote, and the corresponding ``DbtRemoteHook`` to download all required files. An exception would be raised if the scheme does not point to a supported remote.
288+
*airflow-dbt-python* uses the URL scheme (in this example, ``"s3"``) to figure out the type of remote, and the corresponding ``DbtFSHook`` to download all required files. An exception would be raised if the scheme does not point to a supported remote.
289289

290290
*airflow-dbt-python* takes care of adjusting any path-like arguments so that they are pointing to files in a local temporary directory once all the *dbt* files are download from the remote storage.
291291

@@ -320,7 +320,7 @@ The DAG looks the same as the AWS S3 example, except that now we use the GitHub
320320
profile="my-project",
321321
)
322322
323-
*airflow-dbt-python* can determine this URL requires a ``DbtGitRemoteHook`` by looking at the URL's scheme (``"git+ssh"``). As we are passing an SSH URL, ``DbtGitRemoteHook`` can utilize an Airflow `SSH Connection <https://airflow.apache.org/docs/apache-airflow-providers-ssh/stable/connections/ssh.html>`_ as it subclasses Airflow's ``SSHHook``. This connection type allows us to setup the necessary SSH keys to access GitHub. Of course, as this is a public repository, we could have just used an HTTP URL, but for private repositories an SSH key may be required.
323+
*airflow-dbt-python* can determine this URL requires a ``DbtGitFSHook`` by looking at the URL's scheme (``"git+ssh"``). As we are passing an SSH URL, ``DbtGitFSHook`` can utilize an Airflow `SSH Connection <https://airflow.apache.org/docs/apache-airflow-providers-ssh/stable/connections/ssh.html>`_ as it subclasses Airflow's ``SSHHook``. This connection type allows us to setup the necessary SSH keys to access GitHub. Of course, as this is a public repository, we could have just used an HTTP URL, but for private repositories an SSH key may be required.
324324

325325
.. note::
326326
*airflow-dbt-python* can utilize Airflow Connections to fetch connection details for *dbt* remotes as well as for *dbt* targets (e.g. for your data warehouse). The ``project_conn_id`` and ``profiles_conn_id`` arguments that all *dbt* operators have refer to Airflow Connections to used to fetch *dbt* projects and *profiles.yml* respectively, whereas the ``target`` argument can point to an Airflow Connection used to setup *dbt* to access your data warehouse.

docs/how_does_it_work.dot

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ digraph HowDoesItWork {
1818

1919
DbtHook;
2020
DbtOperator -> DbtHook [label="run_dbt_task"];
21-
DbtRemoteHooks -> DbtHook [label="download"];
22-
DbtHook -> DbtRemoteHooks [label="upload", labelfloat=true];
21+
DbtFSHooks -> DbtHook [label="download"];
22+
DbtHook -> DbtFSHooks [label="upload", labelfloat=true];
2323
}
2424

2525
"dbt-core" [style=filled, fillcolor="#CBCBCB", color="#FF7557"];
@@ -34,7 +34,7 @@ digraph HowDoesItWork {
3434
{rank=same; split; DbtOperator; }
3535

3636
"Remote storage" [style=filled, fillcolor="#CBCBCB", color="#FF7557"];
37-
DbtRemoteHooks -> "Remote storage" [headlabel="interacts", labeldistance=4.0];
38-
{rank=same; "Remote storage"; DbtRemoteHooks; }
37+
DbtFSHooks -> "Remote storage" [headlabel="interacts", labeldistance=4.0];
38+
{rank=same; "Remote storage"; DbtFSHooks; }
3939

4040
}

docs/how_does_it_work.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ How does it work?
88
To achieve this goal *airflow-dbt-python* provides Airflow operators, hooks, and other utilities. Hooks in particular come in two flavors:
99

1010
* A ``DbtHook`` that abstracts all interaction with *dbt* internals.
11-
* Subclasses of ``DbtRemoteHook`` that expose an interface to interact with *dbt* remote storages where project files are located (like AWS S3 buckets or git repositories).
11+
* Subclasses of ``DbtFSHook`` that expose an interface to interact with *dbt* remote storages where project files are located (like AWS S3 buckets or git repositories).
1212

1313
.. graphviz:: how_does_it_work.dot
1414

@@ -53,14 +53,14 @@ In order to respect this constraint, *airflow-dbt-python* hooks run each *dbt* c
5353

5454
This ensures *dbt* can work with any Airflow deployment, including most production deployments running `Remote Executors <https://airflow.apache.org/docs/apache-airflow/stable/executor/index.html#executor-types>`_ that do not guarantee any files will be shared between tasks, since each task may run in a completely different worker.
5555

56-
.. _dbt_remote_hooks:
56+
.. _dbt_fs_hooks:
5757

58-
*dbt* remote hooks
58+
*dbt* filesystem hooks
5959
------------------
6060

61-
*dbt* remote hooks implement a simple interface to communicate with *dbt* remotes. A *dbt* remote can be any external storage that contains a *dbt* project and potentially also a *profiles.yml* file for example: an AWS S3 bucket, a Google Cloud Storage or a GitHub repository. See the reference for a list of which remotes are currently supported.
61+
*dbt* fs hooks implement a simple interface to communicate with *dbt* remotes. A *dbt* fs can be any external storage that contains a *dbt* project and potentially also a *profiles.yml* file for example: an AWS S3 bucket, a Google Cloud Storage or a GitHub repository. See the reference for a list of which remotes are currently supported.
6262

63-
Implementing the ``DbtRemoteHook`` interface
63+
Implementing the ``DbtFSHook`` interface
6464
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6565

66-
Supporting a new remote to store *dbt* files requires implementing the ``DbtRemoteHook`` interface. There are only two methods in the interface: ``DbtRemoteHook.download`` and ``DbtRemoteHook.upload``.
66+
Supporting a new fs to store *dbt* files requires implementing the ``DbtFSHook`` interface. There are only two methods in the interface: ``DbtFSHook.download`` and ``DbtFSHook.upload``.

0 commit comments

Comments
 (0)