Skip to content

Commit 8623551

Browse files
committed
file-mode-api: add doc strings to _get_file_transfer_paths
1 parent 8693830 commit 8623551

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

airbyte_cdk/sources/file_based/file_based_stream_reader.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class AbstractFileBasedStreamReader(ABC):
3333
FILE_RELATIVE_PATH = "file_relative_path"
3434
FILE_NAME = "file_name"
3535
LOCAL_FILE_PATH = "local_file_path"
36-
SOURCE_FILE_URI = "source_file_relative_path"
3736
FILE_FOLDER = "file_folder"
3837

3938
def __init__(self) -> None:
@@ -177,8 +176,16 @@ def upload(
177176
...
178177

179178
def _get_file_transfer_paths(
180-
self, source_file_relative_path: str, local_directory: str
179+
self, source_file_relative_path: str, staging_directory: str
181180
) -> MutableMapping[str, Any]:
181+
"""
182+
This method is used to get the file transfer paths for a given source file relative path and local directory.
183+
It returns a dictionary with the following keys:
184+
- FILE_RELATIVE_PATH: The relative path to file in reference to the staging directory.
185+
- LOCAL_FILE_PATH: The absolute path to the file.
186+
- FILE_NAME: The name of the referenced file.
187+
- FILE_FOLDER: The folder of the referenced file.
188+
"""
182189
preserve_directory_structure = self.preserve_directory_structure()
183190

184191
file_name = path.basename(source_file_relative_path)
@@ -188,7 +195,7 @@ def _get_file_transfer_paths(
188195
file_relative_path = source_file_relative_path.lstrip("/")
189196
else:
190197
file_relative_path = file_name
191-
local_file_path = path.join(local_directory, file_relative_path)
198+
local_file_path = path.join(staging_directory, file_relative_path)
192199
# Ensure the local directory exists
193200
makedirs(path.dirname(local_file_path), exist_ok=True)
194201

unit_tests/sources/file_based/test_file_based_stream_reader.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,9 @@ def test_preserve_sub_directories_scenarios(
440440
"""
441441
reader = TestStreamReader()
442442
reader.config = TestSpec(**config)
443-
file_paths = reader._get_file_transfer_paths(source_file_path, "/tmp/transfer-files/")
443+
file_paths = reader._get_file_transfer_paths(
444+
source_file_path, staging_directory="/tmp/transfer-files/"
445+
)
444446

445447
assert (
446448
file_paths[AbstractFileBasedStreamReader.FILE_RELATIVE_PATH] == expected_file_relative_path

0 commit comments

Comments
 (0)