plugin error running from CMD
I am running prom nightly build and I want to run local process mining discovery from command line interface:
my script.txt:
params = new org.processmining.lpm.dialogs.LocalProcessModelParameters();
params.setDiscoveryLog(log);
params.setEvaluationLog(log);
params.setSmartParameterDefaultsForDiscoveryLog();
model = runHeadless(context, params);
for (int i = 0; i < model.getSize(); i++) {
AcceptingPetriNet net = model.getNet(i).getAcceptingPetriNet();
String exportmodel = "/results/petrinet_" + i + ".pnml";
java.io.File exportfile = new java.io.File(exportmodel);
// Export the Petri net to PNML format
PnmlExportNet exporter = new PnmlExportNet();
exporter.exportPetriNetToPNMLFile(context, net, exportfile, PnmlFormat.PNML_1_4);
// Print the export information
print("<export file=\"" + exportmodel + "\">");
print(" <pluginfo>");
print(" <!-- Additional export information, if needed -->");
print(" </pluginfo>");
print(" <bytes>" + exportfile.length() + "</bytes>");
print("</export>");
}
***************************************************
and my batch file is the usual:
@GOTO start
:add
@set X=%X%;%1
@GOTO :eof
:start
@set X=.\dist\ProM-Framework.jar
@set X=%X%;.\dist\ProM-Contexts.jar
@set X=%X%;.\dist\ProM-Models.jar
@set X=%X%;.\dist\ProM-Plugins.jar
@for /R .\lib %%I IN ("*.jar") DO @call :add .\lib\%%~nI.jar
@set IMPORTLOG=EventLog\%1
@set EXPORTMODEL=%2.pnml
@set OUTPUT=.\results\%2.discover.log
.\jre8\bin\java -da -Xmx8G -classpath "%X%" -Djava.library.path=.//lib -Djava.util.Arrays.useLegacyMergeSort=true org.processmining.contexts.cli.CLI -f Scripts/Discover.txt 1> %OUTPUT% 2>&1
set X=
***********************************
It says error:
Error while executing '[-f, Scripts/Discover.txt]'
org.processmining.contexts.scripting.ScriptExecutor$ScriptExecutionException: Sourced file: inline evaluation of: ``print("Discovering..."); importlog = System.getenv("IMPORTLOG"); exportmodel . . . '' : Undefined argument: context : at Line: 58 : in file: inline evaluation of: ``print("Discovering..."); importlog = System.getenv("IMPORTLOG"); exportmodel . . . '' : ( context , params )
Exception in thread "main" org.processmining.contexts.scripting.ScriptExecutor$ScriptExecutionException: Sourced file: inline evaluation of: ``print("Discovering..."); importlog = System.getenv("IMPORTLOG"); exportmodel . . . '' : Undefined argument: context : at Line: 58 : in file: inline evaluation of: ``print("Discovering..."); importlog = System.getenv("IMPORTLOG"); exportmodel . . . '' : ( context , params )
at org.processmining.contexts.scripting.ScriptExecutor.execute(ScriptExecutor.java:109)
at org.processmining.contexts.cli.CLI.main(CLI.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.processmining.framework.boot.Boot.boot(Boot.java:493)
at org.processmining.framework.boot.Boot.boot(Boot.java:460)
at org.processmining.contexts.cli.CLI.main(CLI.java:161)
Caused by: Sourced file: inline evaluation of: ``print("Discovering..."); importlog = System.getenv("IMPORTLOG"); exportmodel . . . '' : Undefined argument: context : at Line: 58 : in file: inline evaluation of: ``print("Discovering..."); importlog = System.getenv("IMPORTLOG"); exportmodel . . . '' : ( context , params )
Comments
-
Hi,
You cannot call a method that requires a plugin context, as you cannot get hold of a proper context. Please replace the following lines:
---8<----
PnmlExportNet exporter = new PnmlExportNet();
exporter.exportPetriNetToPNMLFile(context, net, exportfile, PnmlFormat.PNML_1_4);
---8<----
with the following line:
---8<----
pnml_export_petri_net_(net, exportfile);
---8<----
and then try again.
The executor that runs the script actually knows that this method corresponds to a plugin, and then invokes the proper method while inserting a proper context for you.
In general, if you need to call a plugin from the CLI context, you call it by its declared plugin name. For the PNML exporter, this name is "PNML export (Petri net)" (see the @Plugin annotation for this), which then corresponds to the method name pnml_export_petri_net_: Every upper cases letter becomes a lower case letter, and every series of non alphanumerical characters is replaced by an underscore. Such a plugin method will automatically insert a proper context as the first argument.
Kind regards, Eric.
-
I fixed it and looks like the main problem is with this :
model = runHeadless(context, params);
Error while executing '[-f, Scripts/Discover.txt]'
org.processmining.contexts.scripting.ScriptExecutor$ScriptExecutionException: Sourced file: inline evaluation of: ``print("Discovering..."); importlog = System.getenv("IMPORTLOG"); exportmodel . . . '' : Undefined argument: context : at Line: 59 : in file: inline evaluation of: ``print("Discovering..."); importlog = System.getenv("IMPORTLOG"); exportmodel . . . '' : ( context , params )
I tried model = search_for_local_process_models(log);
but it is not outputting the AcceptingPetriNet
Thank you.
-
Hi,
I see. When I suggested you to use the runHeadless method, I did not realize that it needed a plugin context as first argument, and that this would not work.
Indeed, the result of search_for_local_process_models(log) is an LPMXLog, which basically just wraps the log.
I've now reinstated the older headless plugin that does result in a LocalProcessModelRanking instead of a LPMXLog. This plugin can be called from your script in two ways:
- model = headless_search_for_local_process_models(log)
- model = headless_search_for_local_process_models(params)
The first option creates default parameter values and uses that to discover a local process model from the provided log. The second takes the provided parameter values (which include the log) for the discovery.
See https://github.com/promworkbench/LocalProcessModelDiscovery/blob/main/src/org/processmining/lpm/discovery/LocalProcessModelDiscoveryHeadless.java for details.
This plugin is available in newly released version 6.14.3 of the LocalProcessModelDiscovery package, please update this package first.
Kind regards, Eric.
-
Thank you, this is very helpful. However, a problem that occurs is that in both variants, the methods are lead to a StackOverFlowError.
just calling model = headless_search_for_local_process_models(log) alone leads to this error:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.processmining.framework.plugin.impl.PluginDescriptorImpl.execute(PluginDescriptorImpl.java:331)
at org.processmining.framework.plugin.impl.AbstractPluginDescriptor$1.doInBackground(AbstractPluginDescriptor.java:154)
at org.processmining.framework.plugin.ProMFuture$1.doInBackground(ProMFuture.java:56)
at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at javax.swing.SwingWorker.run(SwingWorker.java:334)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.StackOverflowError
at org.processmining.lpm.discovery.LocalProcessModelDiscoveryHeadless.runHeadless(LocalProcessModelDiscoveryHeadless.java:34)
at org.processmining.lpm.discovery.LocalProcessModelDiscoveryHeadless.runHeadless(LocalProcessModelDiscoveryHeadless.java:34)
at org.processmining.lpm.discovery.LocalProcessModelDiscoveryHeadless.runHeadless(LocalProcessModelDiscoveryHeadless.java:34)
at org.processmining.lpm.discovery.LocalProcessModelDiscoveryHeadless.runHeadless(LocalProcessModelDiscoveryHeadless.java:34)
at org.processmining.lpm.discovery.LocalProcessModelDiscoveryHeadless.runHeadless(LocalProcessModelDiscoveryHeadless.java:34)
-
Hi,
Yes, right. I only tested the other plugin method and did not notice that the second one simply keeps calling itself. A new version (6.14.4) solving this is on its way.
Kind regards, Eric.
Howdy, Stranger!
Categories
- 1.6K All Categories
- 45 Announcements / News
- 225 Process Mining
- 6 - BPI Challenge 2020
- 9 - BPI Challenge 2019
- 24 - BPI Challenge 2018
- 27 - BPI Challenge 2017
- 8 - BPI Challenge 2016
- 68 Research
- 1K ProM 6
- 393 - Usage
- 287 - Development
- 9 RapidProM
- 1 - Usage
- 7 - Development
- 54 ProM5
- 19 - Usage
- 187 Event Logs
- 32 - ProMimport
- 75 - XESame