process_mining / pm4py /examples /bpmn_from_pt_conversion.py
linpershey's picture
Add 'pm4py/' from commit '80970016c5e1e79af7c37df0dd88e17587fe7bcf'
b4ba3ec
raw
history blame
876 Bytes
import os
import pm4py
from pm4py.objects.conversion.process_tree import converter as pt_converter
from pm4py.algo.discovery.inductive import algorithm as inductive_miner
from pm4py.objects.log.importer.xes import importer as xes_import
from pm4py.objects.bpmn.exporter import exporter as bpmn_exporter
from examples import examples_conf
import importlib.util
def execute_script():
log_path = os.path.join(os.path.join("..", "tests", "input_data", "running-example.xes"))
log = xes_import.apply(log_path)
ptree = inductive_miner.apply(log)
bpmn = pt_converter.apply(ptree, variant=pt_converter.Variants.TO_BPMN)
if importlib.util.find_spec("graphviz"):
bpmn_exporter.apply(bpmn, "stru.bpmn")
os.remove("stru.bpmn")
pm4py.view_bpmn(bpmn, format=examples_conf.TARGET_IMG_FORMAT)
if __name__ == "__main__":
execute_script()