-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for generating state diagram without writing the file to disk #533
Comments
Hello @Blindfreddy, I kept you waiting waaaaay too long. The problem is that
from transitions.extensions import GraphMachine
m = GraphMachine(states=['A', 'B'], transitions=[['go', 'A', 'B']], initial='A')
g = m.get_graph().draw(None, prog='dot', format='jpeg')
print(g)
# >>> b'\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01 ... I will have a look to implement a similar behaviour for the |
Hi @aleneum
|
Hi, in 9370834, I implemented the aforementioned behaviour. Let me know if this works for you. If you are happy with your workaround, you can also go ahead and just close this issue. |
I'm afraid I don't know how to install the abovementioned commit using pip prior to release 0.8.9. Tried |
you could just install
|
0.8.9 has been released which includes the requested feature. I will close this issue. Feel free to comment if you consider this issue not resolved. I will reopen the issue if required. |
Is your feature request related to a problem? Please describe.
My program has a REST API and returns data in JSON. I'd like to also return the state diagram rendered using transitions
get_graph().draw()
. Currently, the get_graph().draw() method firstly writes the rendered state diagram to local filesystem, from where I read it, base64 encode it and return it in response to a GET request.Describe the solution you'd like
Render the diagram but don't write it to disk, instead return the stream, or better still directly base64 encode it, thus eliminating the two-step procedure of first writing a file and then reading that file for encoding and returning in the API.
Additional context
Add any other context or screenshots about the feature request here.
Current implementation is as follows; it works but note the two steps: first create the file , then read it and base64 encode it. It would be great if the file were not written to the filesystem but directly returned by the
draw()
method.The text was updated successfully, but these errors were encountered: