Skip to content

Commit ee21bc7

Browse files
committed
refactor to just return file path
fix linting failures
1 parent 9b227c5 commit ee21bc7

File tree

6 files changed

+293
-359
lines changed

6 files changed

+293
-359
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Your Python dependencies can be packaged as .py files, .zip archives (containing
135135
Your entry point script will define logic using the `Client` object which wraps data access layers.
136136

137137
You should only need the following methods:
138-
* `read_file(file_name)` - Returns a file handle of the provided file_name
138+
* `find_file_path(file_name)` - Returns a file path
139139
* `read_dlo(name)` – Read from a Data Lake Object by name
140140
* `read_dmo(name)` – Read from a Data Model Object by name
141141
* `write_to_dlo(name, spark_dataframe, write_mode)` – Write to a Data Model Object by name with a Spark dataframe

src/datacustomcode/client.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
from pyspark.sql import SparkSession
2525

2626
from datacustomcode.config import SparkConfig, config
27-
from datacustomcode.file.reader.default import DefaultFileReader
27+
from datacustomcode.file.path.default import DefaultFindFilePath
2828
from datacustomcode.io.reader.base import BaseDataCloudReader
2929

3030
if TYPE_CHECKING:
31-
import io
31+
from pathlib import Path
3232

3333
from pyspark.sql import DataFrame as PySparkDataFrame
3434

@@ -103,19 +103,21 @@ class Client:
103103
writing, we print to the console instead of writing to Data Cloud.
104104
105105
Args:
106+
finder: Find a file path
106107
reader: A custom reader to use for reading Data Cloud objects.
107108
writer: A custom writer to use for writing Data Cloud objects.
108109
109110
Example:
110111
>>> client = Client()
112+
>>> file_path = client.find_file_path("data.csv")
111113
>>> dlo = client.read_dlo("my_dlo")
112114
>>> client.write_to_dmo("my_dmo", dlo)
113115
"""
114116

115117
_instance: ClassVar[Optional[Client]] = None
116118
_reader: BaseDataCloudReader
117119
_writer: BaseDataCloudWriter
118-
_file: DefaultFileReader
120+
_file: DefaultFindFilePath
119121
_data_layer_history: dict[DataCloudObjectType, set[str]]
120122

121123
def __new__(
@@ -158,7 +160,7 @@ def __new__(
158160
writer_init = writer
159161
cls._instance._reader = reader_init
160162
cls._instance._writer = writer_init
161-
cls._instance._file = DefaultFileReader()
163+
cls._instance._file = DefaultFindFilePath()
162164
cls._instance._data_layer_history = {
163165
DataCloudObjectType.DLO: set(),
164166
DataCloudObjectType.DMO: set(),
@@ -217,10 +219,10 @@ def write_to_dmo(
217219
self._validate_data_layer_history_does_not_contain(DataCloudObjectType.DLO)
218220
return self._writer.write_to_dmo(name, dataframe, write_mode, **kwargs)
219221

220-
def read_file(self, file_name: str) -> io.TextIOWrapper:
222+
def find_file_path(self, file_name: str) -> Path:
221223
"""Read a file from the local file system."""
222224

223-
return self._file.read_file(file_name)
225+
return self._file.find_file_path(file_name)
224226

225227
def _validate_data_layer_history_does_not_contain(
226228
self, data_cloud_object_type: DataCloudObjectType

src/datacustomcode/file/reader/__init__.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/datacustomcode/file/reader/default.py

Lines changed: 0 additions & 203 deletions
This file was deleted.

0 commit comments

Comments
 (0)