Skip to content

Commit

Permalink
Load file util function fix (#483)
Browse files Browse the repository at this point in the history
* Updating load file to return file name fom file path

* Added docstring
  • Loading branch information
johnyrahul authored Jul 12, 2024
1 parent d0b9edb commit c23194e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion backend/workflow_manager/endpoint/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,17 @@ def handle_final_result(
results.append({"file": file_name, "result": result})

def load_file(self, input_file_path: str) -> tuple[str, BytesIO]:
"""Load file contnt and file name based on the file path.
Args:
input_file_path (str): source file
Raises:
InvalidSource: _description_
Returns:
tuple[str, BytesIO]: file_name , file content
"""
connector: ConnectorInstance = self.endpoint.connector_instance
connector_settings: dict[str, Any] = connector.connector_metadata
source_fs: fsspec.AbstractFileSystem = self.get_fsspec(
Expand All @@ -395,7 +406,7 @@ def load_file(self, input_file_path: str) -> tuple[str, BytesIO]:
file_content = remote_file.read()
file_stream = BytesIO(file_content)

return remote_file.key, file_stream
return os.path.basename(input_file_path), file_stream

@classmethod
def add_input_file_to_api_storage(
Expand Down

0 comments on commit c23194e

Please sign in to comment.