Extensions
OCEL extensions let you store and load extra data that is not part of the OCEL 2.0 standard.
Use an extension when your plugin needs custom information to travel with the log (import/export), instead of keeping it in a separate side file.
Defining an OCEL extension
Section titled “Defining an OCEL extension”Create a class that inherits from OCELExtension.
Your extension should:
- describe itself (
name,description,version) - declare which file types it supports (
supported_extensions) - implement:
has_extension(path: Path) -> boolto detect if the file contains the extension dataimport_extension(ocel: OCEL, path: Path) -> OCELExtensionto load the extension dataexport_extension(path: Path) -> Noneto save the extension data
Ocelescope loads and exports extensions based on the OCEL file path suffix (for example .json, .xml, or .sqlite).
Requiring an extension in a plugin method
Section titled “Requiring an extension in a plugin method”If your method depends on an extension being present, declare it on the OCEL input with OCELAnnotation.
Pass the extension class (not an instance).
from typing import Annotated
from ocelescope import OCEL, OCELAnnotation, Plugin, plugin_method
class ExamplePlugin(Plugin): @plugin_method(label="Uses extension") def uses_extension( self, ocel: Annotated[OCEL, OCELAnnotation(label="log", extension=HelloWorldExtension)], ): extension = ocel.extensions.get(HelloWorldExtension) if extension is not None: print(extension.message)
...