-
-
Notifications
You must be signed in to change notification settings - Fork 63
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
lfd
binary for generating diagrams from the command line
#1713
Conversation
@soerendomroes, would you be able to comment on this? |
Not really, but I can try checking it out later today. |
It would be nice if someone could add an example JSON file or string to test this. Where can I find one? @cmnrd |
Our SWT-Mock is the problem. In the real SWT |
@soerendomroes Thanks! I could reproduce your finding when running lfd in a debug session from IntelliJ. Do you know if there is a way to get this output when running from the command line (i.e. directly execute the jar)? I have tried to manually strip the class from the jar, but this alone did not help, and I suspect there might be more errors. Unfortunately, I didn't find a simple way to strip a class from the jar in gradle. Is there an expected time horizon for publishing a new version of kligkd (and SWT-Mock)? |
It is written to the Klighd log This will call the handle(Status) method of the registered StatusManager (or per default the Eclipse status manager). I suppose you could register it an start-up similar to this:
See https://github.com/kieler/KLighD/blob/013d6687ead7fee7041eff36f98e02375e5b2b56/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/KlighdPlugin.java#L71 for an example.
@NiklasRentzCAU can you answer this? |
This has shifted to the top of my priority stack and I will start to look at implementing the Maven stuff as I had planned and start the process necessary to publish on official Maven repositories this week. If everything goes as planned we might have a new release of KLighD and the Mock as P2 Update sites and official Maven artifacts in the following weeks. |
I am just looking at this issue again and notice that releasing KLighD with the SWT mock will not solve your problem here. The SVG export as you currently use it will not work: You solution tries to utilize the BitmapOffscreenRenderer to render the diagram, which does use SWT (the real, platform-dependent SWT, not our mock). The mock will only be required when using the language server, but not for this use case. What you need to use the offscreen renderer is to make sure to pull the real platform-dependent SWT artifacts for this command line tool and build three different versions, one for Windows/MacOSX/Linux each. The mock is only there to make the language server more leight-weight and make it platform-independent (which is exactly why we want to release that now), the Piccolo exporter, however, uses SWT and will need the real artifacts and therefore a more complex build. |
BitmapOffscreenRenderer will not be used, just freehep. |
@soerendomroes Does this mean we can export diagrams without adding the real SWT as a dependency? Since it is possible to export diagrams when using the language server without requiring the real SWT, I assume this should also be possible in a standalone environment. |
No, I am wrong, you need the real SWT for freehep export. If you use a sprotty exporter it should however be possible to build one, but I don't know how. |
Technically possible, but there is no API for that, especially not from KLighD directly. For an "easy" way you will need to use the real SWT for this currently. |
I managed to pull in SWT with gradle (I think), but I still get the same error. Do I have to disable/exclude the SWT Mock explicitly? If so, now? |
Ok, I found a way to exclude the SWT Mock. I also had to add freehep-graphicsio to the dependencies (apparently this is not included automatically by piccolo.freehep). Now I don't see any exceptions anymore, but still I get the message that no offscreen renderer can be found by klighd. Any ideas why? |
I cannot fully pinpoint the issue here, but have a few pointers to make your solution work and to find the issue: First of all, you should not globally exclude the SWT mock from your build, as that will also cause your language server to exclude the mock. The LS, however, definitely should use the mock to keep that platform-independent The unofficial release of the Maven artifacts of KLighD that you use registers the offscreen renderer via service loader and not directly from the standalone setup that you call. It should be registered regardless if your jar/classpath has everything it needs, but you could try the following to fix/find the issue:
|
Today I recreated the changes after our gradle refactoring and spent quite some time debugging and stepping through the plugin registration process. It turned out that there was a class not found exception while registering the SVG renderer, which was masked by an empty catch all statement in klighd. The problem was easily fixed by adding Next I would like to add the diagram synthesis to our tests. For this I would like to detect if an error occured during the diagram generation. Currently, if there is an exception triggerd during the synthesis, there is a backtrace printed and the generated svg also shows an error message. However, there is no indication of failure when rendering the svg. Is there a way to detect that there was an exception during the diagram generation @a-sr, @NiklasRentzCAU? I assume that there is a catch statement somewhere that just catches all exceptions that occurred during the generation. |
You are correct, there are multiple catch statements logging the errors that may occur in different occasions to prevent the entire application from shutting down. For example, you can see that the ViewContext catches an exception and logs that with |
return null; | ||
return reportError(message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am definitely more comfortable with these not being no-ops. But was there a reason why they used to be no-ops? For example, with this change, if someone tries to view a diagram when the model is invalid, will this cause problems, such as duplicated error messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't know. Probably @a-sr can provide more context. I added this forwarding of messages via klighd's logger so that we get proper error reporting in lfd
and can also intercept errors when testing. I don't know what klighd's logger does when we use this from Eclipse or the LSP. The default behavior of the logger is to print to stdout. If this is the case also for Epoch and the LSP, then some additional output in the log should not be problematic. We can try this out, and if we see duplicated messages we can always register a status handler that just discards the messages.
I made some changes today that allow to specify the target OS and also the target architecture (x86_64 or aarch64). This should allow us to easily build all the artifacts in CI. I will later also update the build job. |
lfd
binary for generating diagrams from the command line
This PR adds a new command line tool
lfd
. This tool generates an SVG from a given LF program. Currently, the diagram generation as well as the output format and file name cannot be configured. We can extend lfd with such options in subsequent PRs.This PR also adds a new unit test that smoke tests the diagram synthesis. While checking the concrete diagram output is challenging, this at least tells us if there are any unexpected errors occurring during the diagram generation (like #1833).
The standalone diagram generation via KlighD also requires pulling in SWT as a dependency. SWT is platform specific and, in consequence, we now also need to create platform specific artifacts. This PR also adjusts the nightly release CI job to produce artifacts for Windows, Linux and MacOS for both x86_64 and aarch64 architectures (Windows only uses x86_64 as there is no aarch64 support for Windows in SWT).
Closes #897
Closes #802