Skip to content

Replace Graphviz/DOT with a Java implementation#7557

Open
labkey-adam wants to merge 5 commits intodevelopfrom
fb_graphviz
Open

Replace Graphviz/DOT with a Java implementation#7557
labkey-adam wants to merge 5 commits intodevelopfrom
fb_graphviz

Conversation

@labkey-adam
Copy link
Copy Markdown
Contributor

@labkey-adam labkey-adam commented Apr 7, 2026

Rationale

A native Java implementation is much simpler and cleaner than shelling out to an executable. Switching to https://github.com/jamisonjiang/graph-support

Related Pull Requests

Tasks

  • Dev
  • Code Review
  • Manual Testing - @labkey-jeckels
    • Pipeline diagrams: Admin Console -> Pipelines and Tasks -> clicking some of the pipelines and tasks will show a diagram
    • Group diagrams: go to any permissions page, for example, Site Permissions -> click the Group Diagrams tab
    • Module dependency diagrams require a code change: uncomment the graphModuleDependencies(dependencies, "all") line in ModuleDependencySorter.java (line 84) and compile. Start up the server and examine the file in the temp directory that gets logged.
    • Experiment diagrams. Easily accessed from flow, MS2, and other assays. You'll notice that I'm rendering the new diagrams somewhat larger than the old ones, but monitors are much higher resolution now vs. when we chose the old image-based implementation scaling factor. Current scale factor is arbitrary; we can easily scale it up or down, if desired.
    • Note that pipeline and experiment diagrams currently render both old and new versions for comparison purposes during testing. I plan to remove the old versions before merge.
  • Report minor discrepancies to graph-support project. 1) No support for \L and \R for text alignment. 2) Large margins even when specifying margin="0,0". 3) No support for transparent background.
  • Needs Automation?? I don't think so
  • TeamCity Review and Merge
  • Stop copying executables in the build and distributions
  • Stop installing executables (graphviz) during deployment
  • User education handoff

User Education

  • Add a release note bullet that graphviz is no longer used and can be uninstalled
  • Remove any installation/configuration docs that reference graphviz

@labkey-adam labkey-adam self-assigned this Apr 11, 2026
@labkey-adam labkey-adam added this to the 26.05 milestone Apr 11, 2026
Comment on lines +41 to +45
String units = value.substring(value.length() - 2);
if (StringUtils.isNumeric(units))
units = null;
else
value = value.substring(0, value.length() - 2);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude is concerned about units that aren't two characters.

Issue: The method assumes units are always exactly 2 characters (value.substring(value.length() - 2)). It uses StringUtils.isNumeric(units) to detect "no units". If the last two characters are numeric, units = null (no units). But this fails for values with 1-char units (e.g., "m" or future SVG units), or values where the last character is a digit and second-to-last is a unit letter (e.g., "785pt" with trailing numeric in the number). It also silently uses units for numeric-only 2-char endings. In practice the current SVG output always uses pt or px, so this works today, but the 2-char assumption is fragile.

Why it matters: If graph-support ever outputs different units, parsing would silently fail or corrupt the parsed value.

Suggestion: Use a more robust regex-based approach (e.g., match trailing alpha chars) to separate numeric value from units.

}
else
{
ret = svg.substring(0, idx) + svg.substring(end + 2);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Claude is concerned about assumptions about a trailing space here:

Issue: When size == null (removing the attribute), the code does svg.substring(0, idx) + svg.substring(end + 2). Here end is the position of the closing ". end + 1 is the " itself, so end + 2 skips one character past the closing quote — this is intended to remove the trailing space. But if the attribute is at the end of the tag or is followed by something other than a space, this silently removes an extra character.

Why it matters: Could corrupt the SVG string if attribute is not followed by a space (e.g., the attribute is the last before >).

Suggestion: Check that svg.charAt(end + 1) == ' ' before skipping it, or use a regex replacement.

svgFile.delete();
}
String dot = GroupManager.getGroupGraphDot(groups, getUser(), form.getHideUnconnected());
Graphviz graph = DotParser.parse(dot);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Error handling for the runtime exceptions thrown here?

@labkey-jeckels
Copy link
Copy Markdown
Contributor

Initial testing pass looks OK. Biggest discrepancy is that the new output is significantly taller than the old. That's especially noticeable on the hexagons (which seems fine), but there's also quite a bit more empty space above and below the graph. Maybe that's what you called out in terms of margins.

image

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.

2 participants