Refactor storage service factory and service
This commit is contained in:
parent
b28da3f71a
commit
3f1316b595
2 changed files with 8 additions and 9 deletions
|
|
@ -1,9 +1,8 @@
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
from langflow.services.factory import ServiceFactory
|
from langflow.services.factory import ServiceFactory
|
||||||
from langflow.services.storage.service import StorageService
|
from langflow.services.storage.service import StorageService
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from langflow.services.session.service import SessionService
|
from langflow.services.session.service import SessionService
|
||||||
|
|
@ -19,13 +18,13 @@ class StorageServiceFactory(ServiceFactory):
|
||||||
if storage_type.lower() == "local":
|
if storage_type.lower() == "local":
|
||||||
from .local import LocalStorageService
|
from .local import LocalStorageService
|
||||||
|
|
||||||
return LocalStorageService(session_service)
|
return LocalStorageService(session_service, settings_service)
|
||||||
elif storage_type.lower() == "s3":
|
elif storage_type.lower() == "s3":
|
||||||
from .s3 import S3StorageService
|
from .s3 import S3StorageService
|
||||||
|
|
||||||
return S3StorageService(session_service)
|
return S3StorageService(session_service, settings_service)
|
||||||
else:
|
else:
|
||||||
logger.warning(f"Storage type {storage_type} not supported. Using local storage.")
|
logger.warning(f"Storage type {storage_type} not supported. Using local storage.")
|
||||||
from .local import LocalStorageService
|
from .local import LocalStorageService
|
||||||
|
|
||||||
return LocalStorageService(session_service)
|
return LocalStorageService(session_service, settings_service)
|
||||||
|
|
|
||||||
|
|
@ -20,19 +20,19 @@ class StorageService(Service):
|
||||||
self.ready = True
|
self.ready = True
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def save_file(self, folder: str, file_name: str, data) -> None:
|
def save_file(self, flow_id: str, file_name: str, data) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_file(self, folder: str, file_name: str) -> bytes:
|
def get_file(self, flow_id: str, file_name: str) -> bytes:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def list_files(self, folder: str) -> list[str]:
|
def list_files(self, flow_id: str) -> list[str]:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def delete_file(self, folder: str, file_name: str) -> bool:
|
def delete_file(self, flow_id: str, file_name: str) -> bool:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def teardown(self):
|
def teardown(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue