|
24 | 24 | from pyspark.sql import SparkSession |
25 | 25 |
|
26 | 26 | from datacustomcode.config import SparkConfig, config |
27 | | -from datacustomcode.file.reader.default import DefaultFileReader |
| 27 | +from datacustomcode.file.path.default import DefaultFindFilePath |
28 | 28 | from datacustomcode.io.reader.base import BaseDataCloudReader |
29 | 29 |
|
30 | 30 | if TYPE_CHECKING: |
31 | | - import io |
| 31 | + from pathlib import Path |
32 | 32 |
|
33 | 33 | from pyspark.sql import DataFrame as PySparkDataFrame |
34 | 34 |
|
@@ -103,19 +103,21 @@ class Client: |
103 | 103 | writing, we print to the console instead of writing to Data Cloud. |
104 | 104 |
|
105 | 105 | Args: |
| 106 | + finder: Find a file path |
106 | 107 | reader: A custom reader to use for reading Data Cloud objects. |
107 | 108 | writer: A custom writer to use for writing Data Cloud objects. |
108 | 109 |
|
109 | 110 | Example: |
110 | 111 | >>> client = Client() |
| 112 | + >>> file_path = client.find_file_path("data.csv") |
111 | 113 | >>> dlo = client.read_dlo("my_dlo") |
112 | 114 | >>> client.write_to_dmo("my_dmo", dlo) |
113 | 115 | """ |
114 | 116 |
|
115 | 117 | _instance: ClassVar[Optional[Client]] = None |
116 | 118 | _reader: BaseDataCloudReader |
117 | 119 | _writer: BaseDataCloudWriter |
118 | | - _file: DefaultFileReader |
| 120 | + _file: DefaultFindFilePath |
119 | 121 | _data_layer_history: dict[DataCloudObjectType, set[str]] |
120 | 122 |
|
121 | 123 | def __new__( |
@@ -158,7 +160,7 @@ def __new__( |
158 | 160 | writer_init = writer |
159 | 161 | cls._instance._reader = reader_init |
160 | 162 | cls._instance._writer = writer_init |
161 | | - cls._instance._file = DefaultFileReader() |
| 163 | + cls._instance._file = DefaultFindFilePath() |
162 | 164 | cls._instance._data_layer_history = { |
163 | 165 | DataCloudObjectType.DLO: set(), |
164 | 166 | DataCloudObjectType.DMO: set(), |
@@ -217,10 +219,10 @@ def write_to_dmo( |
217 | 219 | self._validate_data_layer_history_does_not_contain(DataCloudObjectType.DLO) |
218 | 220 | return self._writer.write_to_dmo(name, dataframe, write_mode, **kwargs) |
219 | 221 |
|
220 | | - def read_file(self, file_name: str) -> io.TextIOWrapper: |
| 222 | + def find_file_path(self, file_name: str) -> Path: |
221 | 223 | """Read a file from the local file system.""" |
222 | 224 |
|
223 | | - return self._file.read_file(file_name) |
| 225 | + return self._file.find_file_path(file_name) |
224 | 226 |
|
225 | 227 | def _validate_data_layer_history_does_not_contain( |
226 | 228 | self, data_cloud_object_type: DataCloudObjectType |
|
0 commit comments