PM4Py Examples — Miscellaneous PM4Py Configuration Parameters

Apply these settings to the workflows in process discovery and approximate alignments. For privacy and change-detection workflows, see other analyses.

One of PM4Py's key strengths is its extensive configurability, allowing users to tailor its behavior to specific requirements through environment variables. This configurability supports diverse use cases, from adjusting timestamp formats and visualization settings to enabling multiprocessing and legacy features. By leveraging environment variables, PM4Py provides a seamless way to override default settings without modifying the source code, ensuring adaptability across different environments and workflows.

General Configuration Parameters

The following table details the general configuration parameters of PM4Py, available in the source file pm4py/util/constants.py which control core functionalities such as data parsing, visualization, and performance optimization. Each parameter is linked to an environment variable, allowing users to customize PM4Py's behavior dynamically.

ParameterEnvironment VariablePossible ValuesExplanation
DEFAULT_TIMESTAMP_PARSE_FORMATPM4PY_DEFAULT_TIMESTAMP_PARSE_FORMATString (e.g., "%Y-%m-%d %H:%M:%S"), NoneSpecifies the default timestamp format for parsing. Defaults to "%Y-%m-%d %H:%M:%S" if CUDF is available or testing environment is enabled, otherwise None.
DEFAULT_XES_TIMESTAMP_PARSE_FORMATPM4PY_DEFAULT_XES_TIMESTAMP_PARSE_FORMATString (e.g., "%Y-%m-%dT%H:%M:%S"), "ISO8601"Defines the timestamp format for XES event logs. Defaults to "%Y-%m-%dT%H:%M:%S" if CUDF is available or testing environment is enabled, otherwise "ISO8601".
ENABLE_DATETIME_COLUMNS_AWAREPM4PY_ENABLE_DATETIME_COLUMNS_AWARETrue, FalseControls whether datetime columns are timezone-aware. Defaults to False if CUDF is available or testing environment is enabled, otherwise True.
DEFAULT_ENCODINGPM4PY_DEFAULT_ENCODINGString (e.g., "utf-8")Specifies the default encoding for file operations. Defaults to "utf-8".
DEFAULT_XES_PARSERPM4PY_DEFAULT_XES_PARSER"iterparse", "chunk_regex"Determines the parser for XES files. Defaults to "iterparse" if lxml is available, otherwise "chunk_regex".
DEFAULT_ALIGNMENTS_VARIANTPM4PY_DEFAULT_ALIGNMENTS_VARIANTString (e.g., "Variants.VERSION_STATE_EQUATION_A_STAR")Sets the default variant for alignment computations. Defaults to "Variants.VERSION_STATE_EQUATION_A_STAR".
DEFAULT_BGCOLORPM4PY_DEFAULT_BGCOLORColor (e.g., white)Defines the default background color for visualizations. Defaults to "white".
DEFAULT_FORMAT_GVIZ_VIEWPM4PY_DEFAULT_FORMAT_GVIZ_VIEWString (e.g., "png")Specifies the default format for graph visualizations. Defaults to "png".
DEFAULT_RANKDIR_GVIZPM4PY_DEFAULT_RANKDIR_GVIZString (e.g., "LR")Sets the default rank direction for Graphviz layouts. Defaults to "LR" (left-to-right).
DEFAULT_START_SYMBOL_GRAPHSPM4PY_DEFAULT_START_SYMBOL_GRAPHSString (e.g., "<●>")Defines the default symbol for the start node in graphs. Defaults to "<●>".
DEFAULT_END_SYMBOL_GRAPHSPM4PY_DEFAULT_END_SYMBOL_GRAPHSString (e.g., "<■>")Defines the default symbol for the end node in graphs. Defaults to "<■>".
ENABLE_MULTIPROCESSING_DEFAULTPM4PY_ENABLE_MULTIPROCESSING_DEFAULTTrue, FalseControls whether multiprocessing is enabled by default. Defaults to False.
SHOW_PROGRESS_BARPM4PY_SHOW_PROGRESS_BARTrue, FalseDetermines whether to show progress bars during operations. Defaults to True.
DEFAULT_READ_XES_LEGACY_OBJECTPM4PY_DEFAULT_READ_XES_LEGACY_OBJECTTrue, FalseEnables legacy object reading for XES files. Defaults to False.
DEFAULT_RETURN_DIAGNOSTICS_DATAFRAMEPM4PY_DEFAULT_RETURN_DIAGNOSTICS_DATAFRAMETrue, FalseControls whether diagnostics return a DataFrame. Defaults to False.
DEFAULT_PANDAS_PARSING_DTYPE_BACKENDPM4PY_DEFAULT_PANDAS_PARSING_DTYPE_BACKENDString (e.g., "numpy_nullable")Specifies the Pandas dtype backend for parsing. Defaults to "numpy_nullable".
SHOW_EVENT_LOG_DEPRECATIONPM4PY_SHOW_EVENT_LOG_DEPRECATIONTrue, FalseEnables deprecation warnings for event logs. Defaults to False.
SHOW_INTERNAL_WARNINGSPM4PY_SHOW_INTERNAL_WARNINGSTrue, FalseEnables internal warnings. Defaults to True.
DEFAULT_GVIZ_VIEWPM4PY_DEFAULT_GVIZ_VIEWString (e.g., "view", "matplotlib_view"), NoneSets the default visualization view. Defaults to "matplotlib_view" if running in Power BI, otherwise "view".
DEFAULT_ENABLE_VISUALIZATIONS_VIEWPM4PY_DEFAULT_ENABLE_VISUALIZATIONS_VIEWTrue, FalseEnables visualization views by default. Defaults to True.
DEFAULT_ENABLE_GRAPH_TITLESPM4PY_DEFAULT_ENABLE_GRAPH_TITLESTrue, FalseEnables graph titles by default. Defaults to False.
ENABLE_INTERNAL_IMPORTSPM4PY_ENABLE_INTERNAL_IMPORTSTrue, FalseControls whether internal imports are enabled. Defaults to True.

Set environment variables before the first PM4Py import in a fresh Python process:

Python
import os
os.environ["PM4PY_SHOW_PROGRESS_BAR"] = "False"
os.environ["PM4PY_DEFAULT_FORMAT_GVIZ_VIEW"] = "svg"

from pm4py.util import constants
print("Progress bars:", constants.SHOW_PROGRESS_BAR)
print("Graph format:", constants.DEFAULT_FORMAT_GVIZ_VIEW)
Example Output Configuration read by a fresh Python process after setting the environment variables.
Progress bars: False
Graph format: svg

LLM Module Configuration Parameters

This section lists the LLM (Large Language Model) module configuration parameters from the PM4Py library, their associated environment variables, possible values, and explanations.

ParameterEnvironment VariablePossible ValuesExplanation
OPENAI_MAX_LENPM4PY_OPENAI_MAX_LENInteger (e.g., 10000)Sets the maximum length for OpenAI API responses. Defaults to 10000.
OPENAI_API_KEYPM4PY_OPENAI_API_KEYString, NoneStores the OpenAI API key. Defaults to None.
ANTHROPIC_API_KEYPM4PY_ANTHROPIC_API_KEYString, NoneStores the Anthropic API key. Defaults to None.
GOOGLE_API_KEYPM4PY_GOOGLE_API_KEYString, NoneStores the Google API key. Defaults to None.
OPENAI_API_URLPM4PY_OPENAI_API_URLString (e.g., "https://api.openai.com/v1/")Specifies the OpenAI API endpoint URL. Defaults to "https://api.openai.com/v1/".
OPENAI_DEFAULT_MODELPM4PY_OPENAI_DEFAULT_MODELString (e.g., "gpt-4.1")Sets the default OpenAI model. Defaults to "gpt-4.1".
OPENAI_DEFAULT_VISION_MODELPM4PY_OPENAI_DEFAULT_VISION_MODELString (e.g., "gpt-4.1")Sets the default OpenAI vision model. Defaults to "gpt-4.1".
ANTHROPIC_DEFAULT_MODELPM4PY_ANTHROPIC_DEFAULT_MODELString (e.g., "claude-3-7-sonnet-20250219")Sets the default Anthropic model. Defaults to "claude-3-7-sonnet-20250219".
GOOGLE_DEFAULT_MODELPM4PY_GOOGLE_DEFAULT_MODELString (e.g., "gemini-2.0-flash")Sets the default Google model. Defaults to "gemini-2.0-flash".
OPENAI_DEFAULT_STT_MODELPM4PY_OPENAI_DEFAULT_STT_MODELString (e.g., "whisper-1")Sets the default OpenAI speech-to-text model. Defaults to "whisper-1".
OPENAI_DEFAULT_TTS_MODELPM4PY_OPENAI_DEFAULT_TTS_MODELString (e.g., "tts-1")Sets the default OpenAI text-to-speech model. Defaults to "tts-1".
OPENAI_DEFAULT_TTS_VOICEPM4PY_OPENAI_DEFAULT_TTS_VOICEString (e.g., "alloy")Sets the default OpenAI text-to-speech voice. Defaults to "alloy".
OPENAI_EXEC_RESULTPM4PY_OPENAI_EXEC_RESULTTrue, FalseControls whether OpenAI execution results are enabled. Defaults to False.

LLM Text Abstractions

These functions turn process data into text that can be included in a prompt. They run locally and do not call a language-model service. The examples produce summaries of directly-follows relations, trace variants, and an object-centric DFG.

Python
import pm4py
from pm4py import llm

log = pm4py.read_xes("tests/input_data/running-example.xes")
dfg_text = llm.abstract_dfg(log, include_performance=False, max_len=1200)
variants_text = llm.abstract_variants(log, include_performance=False, max_len=1200)
print(dfg_text)
print(variants_text)
Example Output Locally generated DFG and variant text — Running Example; first six lines of each.
DFG abstraction:
If I have a process with flow:

check ticket -> decide ( frequency = 6 )
examine casually -> check ticket ( frequency = 4 )
register request -> examine casually ( frequency = 3 )
decide -> reject request ( frequency = 3 )

Variant abstraction:
If I have a process with the following process variants:

 register request -> examine casually -> check ticket -> decide -> reinitiate request -> check ticket -> examine casually -> decide -> reini …
 register request -> examine casually -> check ticket -> decide -> reinitiate request -> examine thoroughly -> check ticket -> decide -> pay …
 register request -> examine casually -> check ticket -> decide -> pay compensation ( frequency = 1 )
 register request -> check ticket -> examine casually -> decide -> pay compensation ( frequency = 1 )
… (excerpt)
Python
import pm4py
from pm4py import llm

ocel = pm4py.read_ocel("tests/input_data/ocel/example_log.jsonocel")
print(llm.abstract_ocel_ocdfg(ocel, include_timestamps=False, max_len=1200))
Example Output Locally generated OC-DFG text — example_log.jsonocel; excerpt.
If I have an object-centric event log with the following directly follows graph (split between the different object types):

Object type: element
  "Create Order" -> "Create Delivery" (frequency (number of events) = 4, frequency (number of objects) = 5, duration = 8208000.00)
  "Item back in Stock" -> "Create Delivery" (frequency (number of events) = 1, frequency (number of objects) = 1, duration = 31708800.00)
  "Add Item to Order" -> "Create Delivery" (frequency (number of events) = 1, frequency (number of objects) = 1, duration = 259200.00)
  "Item out of Stock" -> "Item back in Stock" (frequency (number of events) = 1, frequency (number of objects) = 1, duration = 172800.00)
  "Create Order" -> "Item out of Stock" (frequency (number of events) = 1, frequency (number of objects) = 1, duration = 172800.00)

Object type: delivery
  "Create Delivery" -> "Delivery Successful" (frequency (number of events) = 2, frequency (number of objects) = 2, duration = 86400.00)
  "Create Delivery" -> "Delivery Failed" (frequency (number of events) = 1, frequency (number of objects) = 1, duration = 345600.00)

Object type: order
  "Confirm Order" -> "Invoice Sent" (frequency (number of events) = 1, frequency (number of objects) = 1, duration = 777600.00)
  "Add Item to Order" -> "Invoice Sent" (frequency (number of events) = 1, frequency (number of objects) = 1, duration = 432000.00)
… (excerpt)

LLM Connectors

A connector sends a prompt to a language-model service. This example sends a textual DFG abstraction to OpenAI and prints the response. Set PM4PY_OPENAI_API_KEY in your environment before running it; the connector uses the configured default model and API URL from the table above.

Python
import os
import pm4py
from pm4py import llm

log = pm4py.read_xes("tests/input_data/running-example.xes")
dfg_text = llm.abstract_dfg(log, include_performance=False, max_len=1200)
answer = llm.openai_query(
    "Summarize the main paths in this process:\n\n" + dfg_text,
    api_key=os.environ["PM4PY_OPENAI_API_KEY"]
)
print(answer)

Notes

LLM parameters are specific to integrations with OpenAI, Anthropic, and Google APIs, primarily for tasks involving language models, vision, speech-to-text, and text-to-speech. Environment variables must be set to valid API keys or model names for the respective services to function correctly. The OPENAI_EXEC_RESULT parameter determines whether execution results from OpenAI APIs are processed or returned.