fix: Resolve pydantic issue regarding deprecation (#1508)
<!-- .github/pull_request_template.md --> ## Description Fix latest pydantic version issues ## Type of Change <!-- Please check the relevant option --> - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Code refactoring - [ ] Performance improvement - [ ] Other (please specify): ## Screenshots/Videos (if applicable) <!-- Add screenshots or videos to help explain your changes --> ## Pre-submission Checklist <!-- Please check all boxes that apply before submitting your PR --> - [ ] **I have tested my changes thoroughly before submitting this PR** - [ ] **This PR contains minimal changes necessary to address the issue/feature** - [ ] My code follows the project's coding standards and style guidelines - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added necessary documentation (if applicable) - [ ] All new and existing tests pass - [ ] I have searched existing PRs to ensure this change hasn't been submitted already - [ ] I have linked any relevant issues in the description - [ ] My commits have clear and descriptive messages ## DCO Affirmation I affirm that all code in every commit of this pull request conforms to the terms of the Topoteretes Developer Certificate of Origin.
This commit is contained in:
parent
7b5bba2b18
commit
3b8b839057
4 changed files with 756 additions and 856 deletions
|
|
@ -50,26 +50,26 @@ class GraphConfig(BaseSettings):
|
|||
# Model validator updates graph_filename and path dynamically after class creation based on current database provider
|
||||
# If no specific graph_filename or path are provided
|
||||
@pydantic.model_validator(mode="after")
|
||||
def fill_derived(cls, values):
|
||||
provider = values.graph_database_provider.lower()
|
||||
def fill_derived(self):
|
||||
provider = self.graph_database_provider.lower()
|
||||
base_config = get_base_config()
|
||||
|
||||
# Set default filename if no filename is provided
|
||||
if not values.graph_filename:
|
||||
values.graph_filename = f"cognee_graph_{provider}"
|
||||
if not self.graph_filename:
|
||||
self.graph_filename = f"cognee_graph_{provider}"
|
||||
|
||||
# Handle graph file path
|
||||
if values.graph_file_path:
|
||||
if self.graph_file_path:
|
||||
# Check if absolute path is provided
|
||||
values.graph_file_path = ensure_absolute_path(
|
||||
os.path.join(values.graph_file_path, values.graph_filename)
|
||||
self.graph_file_path = ensure_absolute_path(
|
||||
os.path.join(self.graph_file_path, self.graph_filename)
|
||||
)
|
||||
else:
|
||||
# Default path
|
||||
databases_directory_path = os.path.join(base_config.system_root_directory, "databases")
|
||||
values.graph_file_path = os.path.join(databases_directory_path, values.graph_filename)
|
||||
self.graph_file_path = os.path.join(databases_directory_path, self.graph_filename)
|
||||
|
||||
return values
|
||||
return self
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -23,14 +23,14 @@ class RelationalConfig(BaseSettings):
|
|||
model_config = SettingsConfigDict(env_file=".env", extra="allow")
|
||||
|
||||
@pydantic.model_validator(mode="after")
|
||||
def fill_derived(cls, values):
|
||||
def fill_derived(self):
|
||||
# Set file path based on graph database provider if no file path is provided
|
||||
if not values.db_path:
|
||||
if not self.db_path:
|
||||
base_config = get_base_config()
|
||||
databases_directory_path = os.path.join(base_config.system_root_directory, "databases")
|
||||
values.db_path = databases_directory_path
|
||||
self.db_path = databases_directory_path
|
||||
|
||||
return values
|
||||
return self
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -30,21 +30,21 @@ class VectorConfig(BaseSettings):
|
|||
model_config = SettingsConfigDict(env_file=".env", extra="allow")
|
||||
|
||||
@pydantic.model_validator(mode="after")
|
||||
def validate_paths(cls, values):
|
||||
def validate_paths(self):
|
||||
base_config = get_base_config()
|
||||
|
||||
# If vector_db_url is provided and is not a path skip checking if path is absolute (as it can also be a url)
|
||||
if values.vector_db_url and Path(values.vector_db_url).exists():
|
||||
if self.vector_db_url and Path(self.vector_db_url).exists():
|
||||
# Relative path to absolute
|
||||
values.vector_db_url = ensure_absolute_path(
|
||||
values.vector_db_url,
|
||||
self.vector_db_url = ensure_absolute_path(
|
||||
self.vector_db_url,
|
||||
)
|
||||
elif not values.vector_db_url:
|
||||
elif not self.vector_db_url:
|
||||
# Default path
|
||||
databases_directory_path = os.path.join(base_config.system_root_directory, "databases")
|
||||
values.vector_db_url = os.path.join(databases_directory_path, "cognee.lancedb")
|
||||
self.vector_db_url = os.path.join(databases_directory_path, "cognee.lancedb")
|
||||
|
||||
return values
|
||||
return self
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue