diff --git a/README.md b/README.md index 7b975d0..c2b66a7 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,13 @@ Then you can install pygraphviz by running: python3 -m pip install pygraphviz ``` +#### pydot +WfCommons uses _pydot_ for reading and writing DOT files. If you want to enable +this feature, you will have to install the pydot package: +``` +python3 -m pip install pydot +``` + ## Get in Touch The main channel to reach the WfCommons team is via the support email: diff --git a/wfcommons/common/workflow.py b/wfcommons/common/workflow.py index 3031498..55980c1 100644 --- a/wfcommons/common/workflow.py +++ b/wfcommons/common/workflow.py @@ -9,6 +9,7 @@ # (at your option) any later version. import getpass +import importlib import json import networkx as nx import pathlib @@ -181,6 +182,12 @@ def read_dot(self, dot_file_path: Optional[pathlib.Path] = None) -> None: """ if not dot_file_path: raise FileNotFoundError(f"Not able to find the dot file: {dot_file_path}.") + + graphviz_found = importlib.util.find_spec('pydot') + if graphviz_found is None: + raise ModuleNotFoundError( + f"\'pydot\' package not found: call to {type(self).__name__}.read_dot() failed.") + graph = nx.drawing.nx_pydot.read_dot(dot_file_path) tasks_map = {}