zxcalc / quantomatic

Quantomatic is a tool for doing automated graph rewriting.
http://quantomatic.github.io
152 stars 22 forks source link

Headless mode / Jython integration #193

Open rossduncan opened 6 years ago

rossduncan commented 6 years ago

It would be extremely useful to run quantomatic without its GUI, as a batch job. At present if you try to run it without a windowing system it dies on launch, which is definitely not a bug. The features you want to be able to access in the batch mode would most likely be

  1. Open a project
  2. Open a graph in the current project
  3. Apply a simproc to a graph
  4. Save a graph / derivation
  5. Some kind of logging (6) Dump latex of graphs and/or derivations (7) Promote saved derivations to rules Most of this could probably be handled via the simproc API.

I propose that the easiest way to achieve this is to load quanto into a Jython runtime, and use python for the scripting bits (like logging) and call quanto's existing methods from Jython. It's easy to start Jython with quanto loaded : $ jython -Dpython.path=/the/path/to/your/Quantomatic.jar and importing the classes works:

import quanto.gui.QuantoDerive as QD
import quanto.util.Scripting as QS

But trying to initialise quanto or call any methods results in an exception. All the examples listed below failed. (It's possible that I just didn't find the right incantation and all that's needed here is documentation)

QD.loadProject(“/path/to/quanto/project")
quanto = QD()
QD.main(["some arg”])