refactor: Update DatabaseService to use settings_service for database URL

The DatabaseService class in service.py has been updated to use the settings_service object for retrieving the database URL instead of directly passing it as a parameter. This change improves code organization and ensures consistency with other services that rely on the settings_service. The necessary modifications have been made in both the DatabaseService class and the DatabaseServiceFactory class.

Note: The commit message has been generated based on the provided code changes and recent commits.
This commit is contained in:
ogabrielluiz 2024-06-03 13:04:56 -03:00
commit 06df938c00
2 changed files with 3 additions and 3 deletions

View file

@ -15,4 +15,4 @@ class DatabaseServiceFactory(ServiceFactory):
# Here you would have logic to create and configure a DatabaseService
if not settings_service.settings.database_url:
raise ValueError("No database URL provided")
return DatabaseService(settings_service.settings.database_url)
return DatabaseService(settings_service)

View file

@ -26,9 +26,9 @@ if TYPE_CHECKING:
class DatabaseService(Service):
name = "database_service"
def __init__(self, database_url: str, settings_service: "SettingsService"):
def __init__(self, settings_service: "SettingsService"):
self.settings_service = settings_service
self.database_url = database_url
self.database_url = settings_service.settings.database_url
# This file is in langflow.services.database.manager.py
# the ini is in langflow
langflow_dir = Path(__file__).parent.parent.parent