From c885c22c8129f1bfe4ee204c3e1386d5cff5de20 Mon Sep 17 00:00:00 2001 From: v4rgas <66626747+v4rgas@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:40:07 -0300 Subject: [PATCH 1/5] graph_builder --- blarify/examples/graph_builder.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/blarify/examples/graph_builder.py b/blarify/examples/graph_builder.py index 4d93c47a..2015c55a 100644 --- a/blarify/examples/graph_builder.py +++ b/blarify/examples/graph_builder.py @@ -7,13 +7,14 @@ def build(root_path: str = None): - graph_builder = GraphBuilder(root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"]) + graph_builder = GraphBuilder( + root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"], only_hierarchy=True + ) graph = graph_builder.build() relationships = graph.get_relationships_as_objects() nodes = graph.get_nodes_as_objects() - # save_to_neo4j(relationships, nodes) save_to_falkordb(relationships, nodes) From 776f9c0d7aba0e7dfc4f22238b65a66c341903d0 Mon Sep 17 00:00:00 2001 From: v4rgas <66626747+v4rgas@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:40:27 -0300 Subject: [PATCH 2/5] chore: update docs --- docs/quickstart.md | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/quickstart.md b/docs/quickstart.md index 751fd241..2419f28e 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -91,7 +91,7 @@ this will return a list of dictionaries with the following structure } ``` -Example using Neo4j +Example using FalkorDB ```python relationships = graph.get_relationships_as_objects() nodes = graph.get_nodes_as_objects() @@ -111,19 +111,22 @@ graph_manager.close() # Taken from blarify/examples/graph_builder.py from blarify.prebuilt.graph_builder import GraphBuilder from blarify.db_managers.neo4j_manager import Neo4jManager +from blarify.db_managers.falkordb_manager import FalkorDBManager import dotenv import os def build(root_path: str = None): - graph_builder = GraphBuilder(root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"]) + graph_builder = GraphBuilder( + root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"], only_hierarchy=True + ) graph = graph_builder.build() relationships = graph.get_relationships_as_objects() nodes = graph.get_nodes_as_objects() - save_to_neo4j(relationships, nodes) + save_to_falkordb(relationships, nodes) def save_to_neo4j(relationships, nodes): @@ -134,10 +137,23 @@ def save_to_neo4j(relationships, nodes): graph_manager.close() +def save_to_falkordb(relationships, nodes): + graph_manager = FalkorDBManager(repo_id="repo", entity_id="organization") + + print(f"Saving graph with {len(nodes)} nodes and {len(relationships)} relationships") + graph_manager.save_graph(nodes, relationships) + graph_manager.close() + + if __name__ == "__main__": + import logging + + logging.basicConfig(level=logging.INFO) + dotenv.load_dotenv() root_path = os.getenv("ROOT_PATH") build(root_path=root_path) + ``` From 9876a83c520a3568ff8ba297d40dcf1d3443a08a Mon Sep 17 00:00:00 2001 From: Juan Vargas <66626747+v4rgas@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:43:52 -0300 Subject: [PATCH 3/5] Update graph_builder.py --- blarify/examples/graph_builder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blarify/examples/graph_builder.py b/blarify/examples/graph_builder.py index 2015c55a..7a9f2689 100644 --- a/blarify/examples/graph_builder.py +++ b/blarify/examples/graph_builder.py @@ -8,7 +8,7 @@ def build(root_path: str = None): graph_builder = GraphBuilder( - root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"], only_hierarchy=True + root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"] ) graph = graph_builder.build() From 2f522f6ec36cb1ba6854b5672b730d858e1a6f7c Mon Sep 17 00:00:00 2001 From: Juan Vargas <66626747+v4rgas@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:45:27 -0300 Subject: [PATCH 4/5] Update graph_builder.py --- blarify/examples/graph_builder.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/blarify/examples/graph_builder.py b/blarify/examples/graph_builder.py index 7a9f2689..fe6d2c96 100644 --- a/blarify/examples/graph_builder.py +++ b/blarify/examples/graph_builder.py @@ -7,9 +7,7 @@ def build(root_path: str = None): - graph_builder = GraphBuilder( - root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"] - ) + graph_builder = GraphBuilder(root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"]) graph = graph_builder.build() relationships = graph.get_relationships_as_objects() From b77ea03badf769d9588a7187e48249c606edf3e2 Mon Sep 17 00:00:00 2001 From: v4rgas <66626747+v4rgas@users.noreply.github.com> Date: Mon, 24 Feb 2025 17:46:23 -0300 Subject: [PATCH 5/5] chore: update docs --- docs/quickstart.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/quickstart.md b/docs/quickstart.md index 2419f28e..4da8f35b 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -118,9 +118,7 @@ import os def build(root_path: str = None): - graph_builder = GraphBuilder( - root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"], only_hierarchy=True - ) + graph_builder = GraphBuilder(root_path=root_path, extensions_to_skip=[".json"], names_to_skip=["__pycache__"]) graph = graph_builder.build() relationships = graph.get_relationships_as_objects() @@ -153,7 +151,6 @@ if __name__ == "__main__": dotenv.load_dotenv() root_path = os.getenv("ROOT_PATH") build(root_path=root_path) - ```