Generating log with non-local dependencies
Closed this issue · 5 comments
Hi I have been using the PLG2 tool to generate event logs and it has been great to use, so THANKS!
Currently I am trying to incorporate non-local dependencies into the event log by writing attributes to an external file and then reading them later on in the process. The files are getting written but towards the middle of the log generation errors are getting thrown on the StringScriptExecutor
. I suspect it has something to do with my writing to an external file but I am not sure.
Are there any ways to incorporate non-local dependencies into the log generation? I would appreciate any help or pointers.
plg.generator.scriptexecuter.StringScriptExecutor.getValue(StringScriptExecutor.java:26)
plg.generator.scriptexecuter.StringScriptExecutor.getValue(StringScriptExecutor.java:1)
plg.model.data.GeneratedDataObject.generateInstance(GeneratedDataObject.java:55)
plg.generator.log.TraceGenerator.recordEventAttributes(TraceGenerator.java:296)
plg.generator.log.TraceGenerator.recordEventExecution(TraceGenerator.java:271)
plg.generator.log.TraceGenerator.processFlowObject(TraceGenerator.java:137)
plg.generator.log.TraceGenerator.processFlowObject(TraceGenerator.java:187)
plg.generator.log.TraceGenerator.processFlowObject(TraceGenerator.java:187)
plg.generator.log.TraceGenerator.processFlowObject(TraceGenerator.java:187)
plg.generator.log.TraceGenerator.runWithException(TraceGenerator.java:96)
plg.generator.log.TraceGenerator.runWithException(TraceGenerator.java:1)
plg.generator.engine.ThreadWithException.run(ThreadWithException.java:56)
String data object to record cases that have been executed "online".
from __future__ import with_statement
from random import randrange
# This Python script is called for the generation of the string data
# object. Note that the parameter of this function is the actual case
# id of the ongoing simulation (you can use this value to customize
# your data object). The function name has to be "generate".
def generate(caseId):
with open("app_method_online.txt", 'a') as f:
print >> f, caseId
return "online"
Hi! I tried to replicate the problem but I did not succeeded.
The most likely reason of your problem, I guess, is that PLG simulates several traces at the same time (when you start the simulation, on PLG console you have "Starting simulation with x cores"). In your case, you're trying to open the same file concurrently, and this might cause race condition problems. The idea around is to exploit the caseId
variable that is passed to generate
, to have per-trace file names. For example:
from __future__ import with_statement
from random import randrange
def generate(caseId):
with open(caseId + "_app_method_online.txt", 'a') as f:
print >> f, caseId
return "online"
This way, you are sure that the file you are dealing with is always per-trace defined.
Anyway, if you need to simulate non-local dependencies, I have to say that indeed this is not possible out-of-the box. However, I an easier way (wrt using Python) is to model it explicitly (you can import Signavio based BPMN file), and then pretend it was not there.
Let me know if this helps.
Hi! First of all thank you for your answer. The idea to exploit the caseId
variable makes perfect sense. For me, everything goes well with writing to an external file until I try to read its content later on in the process. It throws the plg.generator.scriptexecuter.StringScriptExecutor.getValue(StringScriptExecutor.java:26)
or Integer
depending on the data object. I am thinking that the simulator is trying to read the script data object value before the Python script gets executed, not sure if my reasoning makes sense?
I realized that I have left out a few important detail earlier. I currently have a model in BPMN from Signavio and in PLG2 I am trying to influence the way in which data object values are generated, e.g. if app_method == "online" -> time_lasted(caseId) = randint(1000, 1500). Perhaps it is possible to model that in Signavio. In terms of control flow, I find that you are absolutely right, modeling non-local dependencies in Signavio is a much easier solution. In the end, I think I might have to modify the log afterwards.
Hi. Can you confirm the presence of the bug with this (https://dl.dropboxusercontent.com/u/6792218/plg/model-test.plg) process model?
This is and example rather similar to yours, but I have no exception in this case.
Hi. I have tried your process and it is functioning perfectly. I have tried generating an event log with my designed model again and I have not been able to replicate the earlier exception related to StringScriptExecutor
. However, it does seem to be throwing IOError
from time to time but I have not been able to replicate the error consistently. I have attached a similar model (https://www.dropbox.com/sh/c1ofeclvmx0fd3i/AAB-xc4uBR0x7cbJoV8fwrKFa?dl=0). But for now, I have been able to generate one full log to work with. I will continue to try to find exactly the reason to the exceptions as I generate more logs.
Thank you very much for your help and timely replies!
Good.
Let's monitor future problems with that, and hope to find a way of replicate the issue.