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

contrib: add helper to graph current configuration #1303

Merged

Conversation

liambeguin
Copy link
Contributor

Description

Add a sub-command to sync-places to generate a graphviz graph of the resources and places in a given environment.

A visual representation can help make sense of a large amount of information quickly.
This tried to put all relevant information in one place without being overly complicated.

I also tired to use a color blind friendly palette, not sure how that turned out..

I'm very open to modifying this based on feedback and recommendations.

I also tried to put this into a separate tool using fastapi to have the graph rendered in a browser directly, but ran into trouble. If that approach is preferred I can also push that instead, and maybe with a bit of support we can get it to work consistently.

Testing

$ ./labgrid/contrib/sync-places.py graph | dot -Tsvg -o labgrid-graph.svg

By default the command will just output a dot graph to stdout, piping that to dot we can generate images.

As noted in the docstring, this will generate a graph with:

  • all resources, grouped by groupname and exporter.
  • all places, with a list of tags (a darker shade of blue, if the place is acquired)
  • solid edges between places and acquired resources
  • dotted edges between places and unacquired resources
  • edges between resources and places carry the match name if any.

here's a simple example of what the output looks like:
image

Checklist

  • Documentation for the feature (documented in the docstring)
  • Tests for the feature
  • PR has been tested

Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2d6f93c) 62.7% compared to head (f99c44b) 62.7%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1303   +/-   ##
======================================
  Coverage    62.7%   62.7%           
======================================
  Files         163     163           
  Lines       12001   12001           
======================================
  Hits         7532    7532           
  Misses       4469    4469           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Bastian-Krause
Copy link
Member

Bastian-Krause commented Dec 15, 2023

Does this actually use anything from sync-places.py? Maybe it would be better to have this as a separate script in crontrib/ ?

@liambeguin
Copy link
Contributor Author

Does this actually use anything from sync-places.py?

Not much apart from the "setup". I thought it kind of made sense to group, but I'm happy to separate it. I'll update the PR

@liambeguin
Copy link
Contributor Author

I ended up finding a solution to share the event loop between fastapi and labgrid so I also updated the script to serve the graph in a browser.

contrib/sync-places.py Outdated Show resolved Hide resolved
contrib/graph-places.py Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
@Bastian-Krause Bastian-Krause changed the title contrib: sync-places: add graph sub-command contrib: add helper to graph current configuration Jan 4, 2024
Bastian-Krause
Bastian-Krause previously approved these changes Jan 4, 2024
@liambeguin liambeguin force-pushed the sync-places-graph branch 2 times, most recently from ab523e3 to df8b7ad Compare January 6, 2024 16:48
A visual representation can help make sense of a large configuration
quickly.  As such, add a command line helper to generate a graphviz
graph of the resources and places in a given environment.

By default, this graph will be served on http://localhost:8800/labgrid/graph

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
@liambeguin
Copy link
Contributor Author

I just rebased this MR on the latest master. If there are no other comments I think this would be ready to merge.

@Bastian-Krause Bastian-Krause merged commit be315c0 into labgrid-project:master Feb 5, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants