File tree Expand file tree Collapse file tree 5 files changed +33
-5
lines changed
tests/unit/experimental/pipeline Expand file tree Collapse file tree 5 files changed +33
-5
lines changed Original file line number Diff line number Diff line change 7
7
8
8
### Added
9
9
- Introduction page to the documentation content tree.
10
-
11
- ### Added
12
10
- Introduced a new Vertex AI embeddings class for generating text embeddings using Vertex AI.
13
11
- Updated documentation to include OpenAI and Vertex AI embeddings classes.
14
12
- Added google-cloud-aiplatform as an optional dependency for Vertex AI embeddings.
15
13
14
+ ### Fixed
15
+ - Make ` pygraphviz ` an optional dependency - it is now only required when calling ` pipeline.draw ` .
16
+
17
+
16
18
## 0.6.2
17
19
18
20
### Fixed
Original file line number Diff line number Diff line change @@ -28,6 +28,13 @@ To install the latest stable version, use:
28
28
pip install neo4j-graphrag
29
29
```
30
30
31
+ ### Optional dependencies
32
+
33
+ #### pygraphviz
34
+
35
+ ` pygraphviz ` is used for visualizing pipelines.
36
+ Follow installation instructions [ here] ( https://pygraphviz.github.io/documentation/stable/install.html ) .
37
+
31
38
## Examples
32
39
33
40
### Creating a vector index
Original file line number Diff line number Diff line change 17
17
18
18
from typing import Any
19
19
20
- from neo4j_genai .embedder import Embedder
20
+ from neo4j_graphrag .embedder import Embedder
21
21
22
22
try :
23
23
from vertexai .language_models import TextEmbeddingInput , TextEmbeddingModel
Original file line number Diff line number Diff line change 24
24
from timeit import default_timer
25
25
from typing import Any , AsyncGenerator , Optional
26
26
27
- import pygraphviz as pgv
27
+ try :
28
+ import pygraphviz as pgv
29
+ except ImportError :
30
+ pyg = None
31
+
28
32
from pydantic import BaseModel , Field
29
33
30
34
from neo4j_graphrag .experimental .pipeline .component import Component , DataModel
@@ -386,6 +390,12 @@ def draw(
386
390
G .draw (path )
387
391
388
392
def get_pygraphviz_graph (self , hide_unused_outputs : bool = True ) -> pgv .AGraph :
393
+ if pgv is None :
394
+ raise ImportError (
395
+ "Could not import pygraphviz. "
396
+ "Follow installation instruction in pygraphviz documentation "
397
+ "to get it up and running on your system."
398
+ )
389
399
self .validate_parameter_mapping ()
390
400
G = pgv .AGraph (strict = False , directed = True )
391
401
# create a node for each component
Original file line number Diff line number Diff line change 17
17
import asyncio
18
18
import tempfile
19
19
from unittest import mock
20
- from unittest .mock import AsyncMock , call
20
+ from unittest .mock import AsyncMock , call , patch
21
21
22
22
import pytest
23
23
from neo4j_graphrag .experimental .pipeline import Component , Pipeline
@@ -395,3 +395,12 @@ def test_pipeline_draw() -> None:
395
395
pipe .draw (t .name )
396
396
content = t .file .read ()
397
397
assert len (content ) > 0
398
+
399
+
400
+ @patch ("neo4j_graphrag.experimental.pipeline.pipeline.pgv" , None )
401
+ def test_pipeline_draw_missing_pygraphviz_dep () -> None :
402
+ pipe = Pipeline ()
403
+ pipe .add_component (ComponentAdd (), "add" )
404
+ t = tempfile .NamedTemporaryFile ()
405
+ with pytest .raises (ImportError ):
406
+ pipe .draw (t .name )
You can’t perform that action at this time.
0 commit comments