Merge pull request #190 from topoteretes/COG-575-remove-graph-overwrite-on-error

Remove graph overwriting on exception in NetworkXAdapter
This commit is contained in:
Vasilije 2024-11-12 16:45:43 +01:00 committed by GitHub
commit cdaf63f57c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 2 additions and 8 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

BIN
cognee/.DS_Store vendored Normal file

Binary file not shown.

View file

@ -284,16 +284,10 @@ class NetworkXAdapter(GraphDBInterface):
os.makedirs(file_dir, exist_ok = True)
await self.save_graph_to_file(file_path)
except Exception as e:
logger.error("Failed to load graph from file: %s \n %s", file_path, str(e))
# Initialize an empty graph in case of error
self.graph = nx.MultiDiGraph()
file_dir = os.path.dirname(file_path)
if not os.path.exists(file_dir):
os.makedirs(file_dir, exist_ok = True)
except Exception:
logger.error("Failed to load graph from file: %s", file_path)
await self.save_graph_to_file(file_path)
async def delete_graph(self, file_path: str = None):
"""Asynchronously delete the graph file from the filesystem."""