1010from pytask import ExitCode
1111
1212try :
13- import pydot # noqa: F401
13+ import pygraphviz # noqa: F401
1414except ImportError : # pragma: no cover
15- _IS_PYDOT_INSTALLED = False
15+ _IS_PYGRAPHVIZ_INSTALLED = False
1616else :
17- _IS_PYDOT_INSTALLED = True
17+ _IS_PYGRAPHVIZ_INSTALLED = True
1818
1919_GRAPH_LAYOUTS = ["neato" , "dot" , "fdp" , "sfdp" , "twopi" , "circo" ]
2020
3434
3535
3636@pytest .mark .end_to_end
37- @pytest .mark .skipif (not _IS_PYDOT_INSTALLED , reason = "pydot is required" )
37+ @pytest .mark .skipif (not _IS_PYGRAPHVIZ_INSTALLED , reason = "pygraphviz is required" )
3838@pytest .mark .parametrize ("layout" , _PARAMETRIZED_LAYOUTS )
3939@pytest .mark .parametrize ("format_" , _TEST_FORMATS )
4040@pytest .mark .parametrize ("rankdir" , ["LR" ])
@@ -70,7 +70,7 @@ def task_example(): pass
7070
7171
7272@pytest .mark .end_to_end
73- @pytest .mark .skipif (not _IS_PYDOT_INSTALLED , reason = "pydot is required" )
73+ @pytest .mark .skipif (not _IS_PYGRAPHVIZ_INSTALLED , reason = "pygraphviz is required" )
7474@pytest .mark .parametrize ("layout" , _PARAMETRIZED_LAYOUTS )
7575@pytest .mark .parametrize ("format_" , _TEST_FORMATS )
7676@pytest .mark .parametrize ("rankdir" , [_RankDirection .LR .value , _RankDirection .TB ])
@@ -91,9 +91,9 @@ def task_example(): pass
9191 def task_create_graph():
9292 dag = pytask.build_dag({{"paths": Path(__file__).parent}})
9393 dag.graph = {{"rankdir": "{ rankdir_str } "}}
94- graph = nx.nx_pydot.to_pydot (dag)
94+ graph = nx.nx_agraph.to_agraph (dag)
9595 path = Path(__file__).parent.joinpath("dag.{ format_ } ")
96- graph.write (path, prog="{ layout } ", format=path.suffix[1:] )
96+ graph.draw (path, prog="{ layout } ")
9797 """
9898
9999 tmp_path .joinpath ("task_example.py" ).write_text (textwrap .dedent (source ))
@@ -124,7 +124,7 @@ def task_example(): pass
124124
125125 monkeypatch .setattr (
126126 "_pytask.compat.importlib.import_module" ,
127- lambda x : _raise_exc (ImportError ("pydot not found" )), # noqa: U100
127+ lambda x : _raise_exc (ImportError ("pygraphviz not found" )), # noqa: U100
128128 )
129129
130130 result = runner .invoke (
@@ -133,8 +133,9 @@ def task_example(): pass
133133 )
134134
135135 assert result .exit_code == ExitCode .FAILED
136- assert "pytask requires the optional dependency 'pydot'." in result .output
137- assert "pip or conda" in result .output
136+ assert "pytask requires the optional dependency 'pygraphviz'." in result .output
137+ assert "pip" in result .output
138+ assert "conda" in result .output
138139 assert "Traceback" not in result .output
139140 assert not tmp_path .joinpath ("dag.png" ).exists ()
140141
@@ -150,22 +151,23 @@ def test_raise_error_with_graph_via_task_missing_optional_dependency(
150151
151152 def task_create_graph():
152153 dag = pytask.build_dag({"paths": Path(__file__).parent})
153- graph = nx.nx_pydot.to_pydot (dag)
154+ graph = nx.nx_agraph.to_agraph (dag)
154155 path = Path(__file__).parent.joinpath("dag.png")
155- graph.write (path, prog="dot", format=path.suffix[1:] )
156+ graph.draw (path, prog="dot")
156157 """
157158 tmp_path .joinpath ("task_example.py" ).write_text (textwrap .dedent (source ))
158159
159160 monkeypatch .setattr (
160161 "_pytask.compat.importlib.import_module" ,
161- lambda x : _raise_exc (ImportError ("pydot not found" )), # noqa: U100
162+ lambda x : _raise_exc (ImportError ("pygraphviz not found" )), # noqa: U100
162163 )
163164
164165 result = runner .invoke (cli , [tmp_path .as_posix ()])
165166
166167 assert result .exit_code == ExitCode .FAILED
167- assert "pytask requires the optional dependency 'pydot'." in result .output
168- assert "pip or conda" in result .output
168+ assert "pytask requires the optional dependency 'pygraphviz'." in result .output
169+ assert "pip" in result .output
170+ assert "conda" in result .output
169171 assert "Traceback" in result .output
170172 assert not tmp_path .joinpath ("dag.png" ).exists ()
171173
@@ -211,9 +213,9 @@ def test_raise_error_with_graph_via_task_missing_optional_program(
211213
212214 def task_create_graph():
213215 dag = pytask.build_dag({"paths": Path(__file__).parent})
214- graph = nx.nx_pydot.to_pydot (dag)
216+ graph = nx.nx_agraph.to_agraph (dag)
215217 path = Path(__file__).parent.joinpath("dag.png")
216- graph.write (path, prog="dot", format=path.suffix[1:] )
218+ graph.draw (path, prog="dot")
217219 """
218220 tmp_path .joinpath ("task_example.py" ).write_text (textwrap .dedent (source ))
219221
0 commit comments