API Reference¶
PETRA's public API. Each page below is auto-generated from the
docstrings of the corresponding module — when you change a
docstring in the source code, the next push to main rebuilds
this site and the changes appear here automatically.
| Module | What it covers |
|---|---|
| PetriNet | Core data model — places, transitions, arcs, markings; token-game semantics for both plain and coloured Petri nets. |
| PetriNetModule | The differentiable compiler that turns a PetriNet into a torch.nn.Module. |
| Adapter | TOML scenario loader (load_scenario + ScenarioContext). |
| BPMN | BPMN 2.0 → PetriNet parser. |
| PNML | PNML 2009 P/T-net import / export — the standard Petri-net interchange format. |
| SIF | Pathway Commons / Reactome biology pathway import. |
| XES | IEEE XES execution log loader (plain + gzipped). |
| Traces | Training (train_on_traces), anomaly scoring, sharpness annealing, AUC, expected-cost. |
| Anomalies | Corruption generators (drop_event, insert_event, swap_event_labels, shuffle_events) plus the non-structural FrequencyBaseline. |
| Bisimulation | Strong (are_bisimilar) and weak (are_weakly_bisimilar) bisimulation, plus the reachability-graph foundation they share. |
| Soundness | Aalst soundness verification (check_soundness) and deadlock localisation (find_deadlocks). |
| Coverability | Karp-Miller coverability analysis (coverability_graph, is_bounded) — identifies which places (if any) can hold arbitrarily many tokens. |
| CTL | Computation Tree Logic model checking — six-primitive AST plus the derived AG / AF / EF / AX / AU constructors. |
| Interpretability | Rule extraction, bootstrap CIs, counterfactuals, sensitivity analysis, cross-variant comparison reports, prose explainers. |
| Subnets | Hand-built reference subnets — the five canonical workflow-net building blocks. |
| Process discovery | Inductive Miner — discover_inductive(traces) turns an event log into a sound Petri net; discover_and_train chains the whole discover → verify → compile → train pipeline. |
| ONNX export | Export a trained PetriNetModule to ONNX for deployment to any ONNX runtime (C++, Java, browser, mobile, edge). |
| Streaming evaluator | Per-case real-time anomaly scoring against a live event source — StreamingEvent, StreamingEvaluator, push/pull shapes. |
| REST API | build_app(module) returns a FastAPI app exposing six endpoints (/healthz, /schema, /forward, /anomaly, /counterfactual, /sensitivity) for non-Python consumers. |
| Command-line interface | petra-train / petra-score / petra-serve entry points — engine-team integration story, see also Integration Patterns. |