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.
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.
| Parameter | Environment Variable | Possible Values | Explanation |
|---|---|---|---|
DEFAULT_TIMESTAMP_PARSE_FORMAT | PM4PY_DEFAULT_TIMESTAMP_PARSE_FORMAT | String (e.g., "%Y-%m-%d %H:%M:%S"), None | Specifies 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_FORMAT | PM4PY_DEFAULT_XES_TIMESTAMP_PARSE_FORMAT | String (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_AWARE | PM4PY_ENABLE_DATETIME_COLUMNS_AWARE | True, False | Controls whether datetime columns are timezone-aware. Defaults to False if CUDF is available or testing environment is enabled, otherwise True. |
DEFAULT_ENCODING | PM4PY_DEFAULT_ENCODING | String (e.g., "utf-8") | Specifies the default encoding for file operations. Defaults to "utf-8". |
DEFAULT_XES_PARSER | PM4PY_DEFAULT_XES_PARSER | "iterparse", "chunk_regex" | Determines the parser for XES files. Defaults to "iterparse" if lxml is available, otherwise "chunk_regex". |
DEFAULT_ALIGNMENTS_VARIANT | PM4PY_DEFAULT_ALIGNMENTS_VARIANT | String (e.g., "Variants.VERSION_STATE_EQUATION_A_STAR") | Sets the default variant for alignment computations. Defaults to "Variants.VERSION_STATE_EQUATION_A_STAR". |
DEFAULT_BGCOLOR | PM4PY_DEFAULT_BGCOLOR | Color (e.g., white) | Defines the default background color for visualizations. Defaults to "white". |
DEFAULT_FORMAT_GVIZ_VIEW | PM4PY_DEFAULT_FORMAT_GVIZ_VIEW | String (e.g., "png") | Specifies the default format for graph visualizations. Defaults to "png". |
DEFAULT_RANKDIR_GVIZ | PM4PY_DEFAULT_RANKDIR_GVIZ | String (e.g., "LR") | Sets the default rank direction for Graphviz layouts. Defaults to "LR" (left-to-right). |
DEFAULT_START_SYMBOL_GRAPHS | PM4PY_DEFAULT_START_SYMBOL_GRAPHS | String (e.g., "<●>") | Defines the default symbol for the start node in graphs. Defaults to "<●>". |
DEFAULT_END_SYMBOL_GRAPHS | PM4PY_DEFAULT_END_SYMBOL_GRAPHS | String (e.g., "<■>") | Defines the default symbol for the end node in graphs. Defaults to "<■>". |
ENABLE_MULTIPROCESSING_DEFAULT | PM4PY_ENABLE_MULTIPROCESSING_DEFAULT | True, False | Controls whether multiprocessing is enabled by default. Defaults to False. |
SHOW_PROGRESS_BAR | PM4PY_SHOW_PROGRESS_BAR | True, False | Determines whether to show progress bars during operations. Defaults to True. |
DEFAULT_READ_XES_LEGACY_OBJECT | PM4PY_DEFAULT_READ_XES_LEGACY_OBJECT | True, False | Enables legacy object reading for XES files. Defaults to False. |
DEFAULT_RETURN_DIAGNOSTICS_DATAFRAME | PM4PY_DEFAULT_RETURN_DIAGNOSTICS_DATAFRAME | True, False | Controls whether diagnostics return a DataFrame. Defaults to False. |
DEFAULT_PANDAS_PARSING_DTYPE_BACKEND | PM4PY_DEFAULT_PANDAS_PARSING_DTYPE_BACKEND | String (e.g., "numpy_nullable") | Specifies the Pandas dtype backend for parsing. Defaults to "numpy_nullable". |
SHOW_EVENT_LOG_DEPRECATION | PM4PY_SHOW_EVENT_LOG_DEPRECATION | True, False | Enables deprecation warnings for event logs. Defaults to False. |
SHOW_INTERNAL_WARNINGS | PM4PY_SHOW_INTERNAL_WARNINGS | True, False | Enables internal warnings. Defaults to True. |
DEFAULT_GVIZ_VIEW | PM4PY_DEFAULT_GVIZ_VIEW | String (e.g., "view", "matplotlib_view"), None | Sets the default visualization view. Defaults to "matplotlib_view" if running in Power BI, otherwise "view". |
DEFAULT_ENABLE_VISUALIZATIONS_VIEW | PM4PY_DEFAULT_ENABLE_VISUALIZATIONS_VIEW | True, False | Enables visualization views by default. Defaults to True. |
DEFAULT_ENABLE_GRAPH_TITLES | PM4PY_DEFAULT_ENABLE_GRAPH_TITLES | True, False | Enables graph titles by default. Defaults to False. |
ENABLE_INTERNAL_IMPORTS | PM4PY_ENABLE_INTERNAL_IMPORTS | True, False | Controls whether internal imports are enabled. Defaults to True. |
Set environment variables before the first PM4Py import in a fresh Python process:
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)Progress bars: False
Graph format: svgThis section lists the LLM (Large Language Model) module configuration parameters from the PM4Py library, their associated environment variables, possible values, and explanations.
| Parameter | Environment Variable | Possible Values | Explanation |
|---|---|---|---|
OPENAI_MAX_LEN | PM4PY_OPENAI_MAX_LEN | Integer (e.g., 10000) | Sets the maximum length for OpenAI API responses. Defaults to 10000. |
OPENAI_API_KEY | PM4PY_OPENAI_API_KEY | String, None | Stores the OpenAI API key. Defaults to None. |
ANTHROPIC_API_KEY | PM4PY_ANTHROPIC_API_KEY | String, None | Stores the Anthropic API key. Defaults to None. |
GOOGLE_API_KEY | PM4PY_GOOGLE_API_KEY | String, None | Stores the Google API key. Defaults to None. |
OPENAI_API_URL | PM4PY_OPENAI_API_URL | String (e.g., "https://api.openai.com/v1/") | Specifies the OpenAI API endpoint URL. Defaults to "https://api.openai.com/v1/". |
OPENAI_DEFAULT_MODEL | PM4PY_OPENAI_DEFAULT_MODEL | String (e.g., "gpt-4.1") | Sets the default OpenAI model. Defaults to "gpt-4.1". |
OPENAI_DEFAULT_VISION_MODEL | PM4PY_OPENAI_DEFAULT_VISION_MODEL | String (e.g., "gpt-4.1") | Sets the default OpenAI vision model. Defaults to "gpt-4.1". |
ANTHROPIC_DEFAULT_MODEL | PM4PY_ANTHROPIC_DEFAULT_MODEL | String (e.g., "claude-3-7-sonnet-20250219") | Sets the default Anthropic model. Defaults to "claude-3-7-sonnet-20250219". |
GOOGLE_DEFAULT_MODEL | PM4PY_GOOGLE_DEFAULT_MODEL | String (e.g., "gemini-2.0-flash") | Sets the default Google model. Defaults to "gemini-2.0-flash". |
OPENAI_DEFAULT_STT_MODEL | PM4PY_OPENAI_DEFAULT_STT_MODEL | String (e.g., "whisper-1") | Sets the default OpenAI speech-to-text model. Defaults to "whisper-1". |
OPENAI_DEFAULT_TTS_MODEL | PM4PY_OPENAI_DEFAULT_TTS_MODEL | String (e.g., "tts-1") | Sets the default OpenAI text-to-speech model. Defaults to "tts-1". |
OPENAI_DEFAULT_TTS_VOICE | PM4PY_OPENAI_DEFAULT_TTS_VOICE | String (e.g., "alloy") | Sets the default OpenAI text-to-speech voice. Defaults to "alloy". |
OPENAI_EXEC_RESULT | PM4PY_OPENAI_EXEC_RESULT | True, False | Controls whether OpenAI execution results are enabled. Defaults to False. |
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.
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)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)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))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) 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.
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) 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.