Skip to content

Commit

Permalink
Addition of doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
harini-venkataraman authored Nov 26, 2024
1 parent c9c83db commit e9b7111
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions backend/utils/file_storage/helpers/prompt_studio_file_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ def get_or_create_prompt_studio_subdirectory(
def upload_for_ide(
org_id: str, user_id: str, tool_id: str, uploaded_file: Any
) -> None:
""" Uploads the file to a remote storage
Args:
org_id (str): Organization ID
user_id (str): User ID
tool_id (str): ID of the prompt studio tool
uploaded_file : File to upload to remote
"""
fs_instance = FileStorageHelper.initialize_file_storage(
type=FileStorageType.PERMANENT
)
Expand All @@ -67,6 +75,8 @@ def upload_for_ide(
def fetch_file_contents(
org_id: str, user_id: str, tool_id: str, file_name: str
) -> Union[bytes, str]:
""" Method to fetch file contents from the remote location.
The path is constructed in runtime based on the args """
fs_instance = FileStorageHelper.initialize_file_storage(
type=FileStorageType.PERMANENT
)
Expand Down Expand Up @@ -126,6 +136,9 @@ def fetch_file_contents(

@staticmethod
def delete_for_ide(org_id: str, user_id: str, tool_id: str, file_name: str) -> bool:
""" Method to delete file in remote while the corresponsing prompt
studio project is deleted or the file is removed from the file manager.
This method handles deleted for related files as well."""
fs_instance = FileStorageHelper.initialize_file_storage(
type=FileStorageType.PERMANENT
)
Expand Down Expand Up @@ -157,6 +170,10 @@ def delete_for_ide(org_id: str, user_id: str, tool_id: str, file_name: str) -> b
def _find_files(
fs: FileStorage, base_file_name: str, base_path: str, directories: list[str]
) -> list[str]:
""" This method is used to file files with the specific pattern
determined using the list of directories passed and the base path.
This is used to delete related(extract, metadata etc.) files generated
for a specific prompt studio project."""
file_paths = []
pattern = f"{base_file_name}.*"
for directory in directories:
Expand Down

0 comments on commit e9b7111

Please sign in to comment.