Skip to content
v0.2.1

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.

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) -> bool to detect if the file contains the extension data
    • import_extension(ocel: OCEL, path: Path) -> OCELExtension to load the extension data
    • export_extension(path: Path) -> None to save the extension data

Ocelescope loads and exports extensions based on the OCEL file path suffix (for example .json, .xml, or .sqlite).

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)
...