4 ms·
Python Generated Sequence Diagrams
- bobthepanda 6y agoNeat! What text->diagram tools do you guys prefer? I am partial to PlantUML: https://plantuml.com/ https://plantuml.com/
- codegladiator 6y agoI use this https://www.websequencediagrams.com/ https://www.websequencediagrams.com/ a lot
- andreareina 6y agoditaa[1] for ascii art, Graphviz[2] for node-and-edge stuff, PlantUML for the rest [1] http://ditaa.sourceforge.net/ http://ditaa.sourceforge.net/ [2] https://graphviz.org/ https://graphviz.org/
- ngcc_hk 6y agoUse graphviz as well. That look very verbose. Btw learn graphviz via the lisp one game at a time.
- andreareina 6y agoLand of Lisp? I don't remember if that's how I came across graphviz, but it was my introduction to generating svg.
- achamayou 6y agoMermaid (https://mermaid-js.github.io/ https://mermaid-js.github.io/) is excellent, easy to embed inline in Markdown or reStructuredText and to version with the rest of the documentation.
- timvdalen 6y agoI really like mscgen[1], partly because the syntax is very GraphViz-like, which feels familiar. [1]: http://www.mcternan.me.uk/mscgen/ http://www.mcternan.me.uk/mscgen/
- jianyuan 6y agoDiagram as Code: https://github.com/mingrammer/diagrams https://github.com/mingrammer/diagrams
- wegs 6y agoNeat! What I really wish for is integration, or at least discovery. I run into posts like this all the time, see neat things, and then can never find them again. I like all-in-one libraries like pylab/matplotlib where I know where to look. The corollary is that if this could be folded into something, it'd probably see more use. But I'm not sure what. Or perhaps an alternative might be to have all libraries like this categorized in some way. I'm not quite sure how, though.
- rgoulter 6y agoWhile it's good to see the results you can get from familiarity with imagemagick drawing commands and a small script, for more sophisticated scenarios (or customisation), you can still get "rendered from text on my computer" using tools like PlantUML. (Or GraphViz for graphs, etc.). Embedding the resulting diagrams in the text editor (like Emacs' org-babel allows for) makes for a nice diagramming experience.
- smitty1e 6y agoThat's an excellent point. While we should reach for prior art, something like this bit of python is good for the hip pocket for those moments when PlantUML might not support some zany requirement.
- lipeltgm 6y agoAgreed and for a few years now that's what I have done. But for detailed, log/debug driven sequence diagrams that often required parsing a log, generating a compliant text-input to the tools followed by submitting to the tool and exporting the graphic. This 30-minute project is a step in the direction to fully automate the process.
- motohagiography 6y agoAs a security guy, this python seq diagram view would be super valuable as essentially a markup language for BAN logic for documenting encryption and key management schemes. https://en.wikipedia.org/wiki/Burrows%E2%80%93Abadi%E2%80%93Needham_logic https://en.wikipedia.org/wiki/Burrows%E2%80%93Abadi%E2%80%93... Oddly, I've never heard this called "security protocol notation" before, but apparently that's a thing as well. https://en.wikipedia.org/wiki/Security_protocol_notation https://en.wikipedia.org/wiki/Security_protocol_notation
- karlicoss 6y agoNice! I did something similar for my personal infrastructure map [0]. I tried different tools, and each of them was too limited so landed on graphviz + a python DSL [1] to generate the diagram. It turned out to be extremely convenient: - python makes it easy to spot errors/typos (you can use mypy even before running the genrator) - keyword arguments and dictionaries map naturally to node/edge properties - you can reuse boilerplate by using functions, variables and control structures - you can always inject graphviz string directly as a last resort hacking measure - thanks to python's dynamic features, you can even give the nodes/clusters same names as their corresponding python objects, which results in less boilerplate and makes easy to debug [0] https://beepb00p.xyz/myinfra.html https://beepb00p.xyz/myinfra.html [1] https://github.com/karlicoss/myinfra/blob/master/generate.py https://github.com/karlicoss/myinfra/blob/master/generate.py
- cgranier 6y agoWow... I'm really enjoying reading about promnesia, roam integration, etc. Thanks for sharing.
- ris 6y agoWhen needing to do something similar (with our pseudo-microservice project's increasingly incomprehensible JSON logs) I also wanted the diagram to be interactive so it's possible to "dig" when showing larger amounts of data, so I learned d3.js and was very pleasantly surprised by the power of the abstraction it introduces, despite the unavoidable javascript. https://github.com/alphagov/digitalmarketplace-logdia https://github.com/alphagov/digitalmarketplace-logdia (ended up having to turn it into a custom WebExtension just so it could integrate "easily" with kibana by monkeypatching & intercepting its xhr requests, let's not get into that...)
- seesawtron 6y agoIs anyone else struggling to run it? I keep getting the error at line 67: ValueError: invalid literal for int() with base 10: '' Changed it to float before int casting but still the same error.
- lipeltgm 6y agoWhat value are you encountering for list 'D' when you get the error? As you can see from the code, not really production-grade coding and certainly not heavily tested, proof-of-concept more than anything else.
- seesawtron 6y agoI tried running it with jupyterlab. I had issues with executing imagemagick commands which is why the temp.jpg file didn't get created causing the error (list D is empty).
- bbrik 6y agoVery cool. Why all those semi-colons in your code?
- lipeltgm 6y agoI doubt it'll be a popular response, but despite Python not requiring semicolons while many do (or most languages I use), I simply tend to end all statements with semicolons as a personal preference.
- th5 6y agoAsciiFlow.com ! Not text to diagram, but creating diagrams in text that I check-in to the comments at the top of my code.