pytransitions / transitions

A lightweight, object-oriented finite state machine implementation in Python with many extensions
MIT License
5.49k stars 525 forks source link

Error if pygraphviz is not installed #569

Closed FridjofAmundsen closed 1 year ago

FridjofAmundsen commented 2 years ago

graphviz is not used as fallback if pygraphviz is not available, an error is thrown. In Version 8.1 'graphviz' was used as a fallback.

Minimal working example

from transitions.extensions import GraphMachine
class Model:
    pass
machine = GraphMachine(model=Model())

Expected behavior I expect that in this case graphviz is used as a fallback.

workaround

import pkgutil
from transitions.extensions import GraphMachine

class Model:
    pass
has_pygraphviz = pkgutil.find_loader('pygraphviz')
machine = GraphMachine(model=Model(),  use_pygraphviz=has_pygraphviz )

Additional context the following patch would solve this issue. fallback_to_graphviz_patch.zip

aleneum commented 2 years ago

Hello @FridjofAmundsen,

thanks for the report and sorry for the regression. I will have a look whether we can easily integrate this as a test case.

FridjofAmundsen commented 2 years ago

@aleneum thanks. You don't have to apologize. I’m really happy that you put so much effort into this project.