Skip to content

Commit 219faa4

Browse files
committed
[#1397] make message flow docs helpers robust to optional Graphviz
The scenario message-flow SVGs are documentation artifacts, so normal scenario tests should not fail just because the Graphviz `dot` executable is not installed. Make `saveScenarioGraphvizFigure()` return quietly when Graphviz is unavailable, while preserving SVG generation in docs jobs where Graphviz is installed. Also install the recorder source hook at `SimulationBaseClass` import time. This lets the message-flow graph recover recorder connections even when a recorder is created before the `SimBaseClass` instance.
1 parent c0f9f95 commit 219faa4

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

src/utilities/SimulationBaseClass.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,9 @@ def recorderWithSource(self, *args, _recorderMethod=recorderMethod, **kwargs):
553553
pass
554554

555555

556+
_ensureRecorderSourceHooks()
557+
558+
556559
class SimBaseClass:
557560
"""Simulation Base Class"""
558561

src/utilities/tests/test_SimulationBaseClass.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,26 @@ def test_GetMessageConnectionGraph_with_recorder():
305305
assert ("dataOutMsg", "recordedMsg") in edgePairs
306306

307307

308+
def test_GetMessageConnectionGraph_with_recorder_before_sim_creation():
309+
"""Check recorder source tracking before creating the simulation object."""
310+
cModule = cModuleTemplate.cModuleTemplate()
311+
cModule.ModelTag = "cModule"
312+
dataRec = cModule.dataOutMsg.recorder()
313+
314+
scSim = SimulationBaseClass.SimBaseClass()
315+
testProcess = scSim.CreateNewProcess("testProcess")
316+
simulationTimeStep = macros.sec2nano(1.0) # [ns]
317+
testProcess.addTask(scSim.CreateNewTask("testTask", simulationTimeStep))
318+
319+
scSim.AddModelToTask("testTask", cModule)
320+
scSim.AddModelToTask("testTask", dataRec)
321+
322+
graph = scSim.GetMessageConnectionGraph(includeUnlinked=False)
323+
edgePairs = {(edge["sourceName"], edge["targetName"]) for edge in graph["edges"]}
324+
325+
assert ("dataOutMsg", "recordedMsg") in edgePairs
326+
327+
308328
def test_GetMessageConnectionGraph_with_input_message_recorder():
309329
"""Check that input message recorders show their recorded input."""
310330
scSim = SimulationBaseClass.SimBaseClass()

0 commit comments

Comments
 (0)