Skip to content
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

initial graph #56

Merged
merged 12 commits into from
May 20, 2022
Merged

initial graph #56

merged 12 commits into from
May 20, 2022

Conversation

yankovs
Copy link
Contributor

@yankovs yankovs commented May 9, 2022

Karton graph visualization

graph

Introduction

This pull request adds a visualization of the kartons and the connections between them. A graph tab is added to the dashboard, and in it a directed graph. The graph is interactive, allowing zooming, moving the graph and moving the nodes. A click on a node shows info about it: its name, version (if available) and description (if available).

In more details

Stack used

  • echarts.js - for the visualization
  • marked.js - for description parsing
  • DOMPurify - to sanitize the description
  • networkx - for graph building in the backend, also used to generate a gexf of the graph

Implementation details

A /graph route was added. When accessing it, the graph is built out of the binds and the outputs in redis. For each karton we create a KartonNode object representing it, which then allows to see if one karton should have an edge to another (i.e., if the former karton's outputs are contained in the latter's binds).

After creating a graph object, we style it and provide size and color for each node. We then output it in gexf format. This gexf format graph is passed to the frontend. An echarts instance is created from the graph and displayed.

Possible uses

A few possible uses for the graph might be:

  • Discovery of faulty kartons; If a karton doesn't have any incoming or outgoing edges it might indicate of a problem
  • Karton cycle detection; Is it okay that there's a loop between kartons?
  • General karton system health checks

Future work

  • Currently the graph is calculated each time /graph is accessed, maybe some caching mechanism can be used
  • Currently the backend it blocking when requesting /graph so a user needs to wait until they get the graph with a reasonably big karton system changed so now a loading screen shows, but loading time should still be addressed
  • Organize the graph in a better way, maybe as something that resembles a directed acyclic graph (although it is not acyclic)
  • Implement highlighting of the cycles in the graph
  • Implement highlighting all of the paths between two nodes in the graph

requirements.txt Outdated Show resolved Hide resolved
@nazywam
Copy link
Member

nazywam commented May 16, 2022

Looks great, thanks for the contribution! <3

I've written down a few notes while playing around with it, we don't have to include them in this PR but if you agree with some of them I'll create issues to keep track & sort them out in the future.

Good to have:

  • host the js dependencies locally - always nice to have your application self-contained
  • visualize dead/inactive services - using a partial alpha or some icon maybe?
  • add a slight duration when focusing a given edge/node - right now if you wave the cursor around the screen ends up flashing quite a bit and this can get annoying when using the graph regularly. I've tried to find the option responsible in echart but failed :(

Nice to have/loose ideas:

  • the navbar is skewed a bit to the right (when compared to other subpages)
  • show information about possible task headers in edges
  • visualize number of tasks as edge weight - not even sure we store enough data right now to calculate that

Again, thanks for your contribution!
I'll give @psrok1 chance to take a look as well and then we'll get this merged!

yankovs and others added 3 commits May 16, 2022 13:52
Co-authored-by: Michał Praszmo <nazywam@gmail.com>
This changed is to fix the graph flickering when just mousing over the edges as pointed by @nazywam
animationDelay doesn't achieve what it needs to; Also removed depracated focusNodeAdjacency in favor of `emphasis: {focus: 'adjacency'}` and dispatchAction of type `focusNodeAdjacency` which doesn't exists anymore
@nazywam nazywam requested a review from psrok1 May 20, 2022 09:22
@psrok1 psrok1 force-pushed the feature/graph branch 2 times, most recently from e23fa4a to b23bbd5 Compare May 20, 2022 14:23
Copy link
Member

@psrok1 psrok1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's great ❤️ As @nazywam said before: there is some room for improvements, but as an initial version I think it's ready to merge. Huge thanks for that feature.

Sidenote: I applied small fixes on my own (mainly related with typings): 650e510

Copy link
Member

@nazywam nazywam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

@psrok1 psrok1 merged commit 0a9751d into CERT-Polska:master May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Karton v4.4.0 isn't compatible with task cancelling
4 participants