Interactive mode
For a question too small for a script, run python -m syside interactive your_model.sysml: a Python shell with that model already loaded, where one line
checks for errors or counts elements, and the answer comes back immediately.
Note
Interactive mode runs an IPython shell when
IPython is installed, which is what this page shows. To get it, install Syside with
the ipython extra: pip install "syside[ipython]" (or, with uv, uv add "syside[ipython]"), as Install Automator describes. Without IPython, a plain
Python shell is used instead, with different prompts and less convenient multi-line
input.
Learn about:
Checking for errors: Quickly identify errors in the model
Counting parts: Run short scripts rather than full Python scripts
Complex commands: Forming more complex commands interactively
Example Model: copy this model into your example_model.sysml file to test out
the features of interactive mode, or use your own model:
package 'Part Tree Example' {
part def Electrical;
part def Mechanical;
part Automobile {
part 'Drive Train' {
part Battery : Electrical;
part Motor : Electrical;
}
part Chassis {
part Suspension : Mechanical;
part Body : Mechanical;
}
}
}
Checking for errors
Automate your first model check checks a model with syside check. Starting
interactive mode runs the same check on the way in: the command loads the model
with load_model, which raises on any error it finds, so a model with
errors prints them and no shell opens.
To see it, remove the line part def Electrical; from the model and start
interactive mode again:
python -m syside interactive example_model.sysml
It prints the errors and returns to your terminal:
example_model.sysml:6:28: error (reference-error): No Type named 'Electrical' found.
6 | part Battery : Electrical;
| ^^^^^^^^^^
example_model.sysml:7:26: error (reference-error): No Type named 'Electrical' found.
7 | part Motor : Electrical;
| ^^^^^^^^^^
Counting parts
One advantage of interactive mode is the ability to run simple scripts that do
not warrant a full Python script. Restore the part def Electrical; line removed in
the previous section and start the interactive session again:
python -m syside interactive example_model.sysml
Since the model is now valid, Syside drops into a shell with the model already loaded, greeting you with a banner similar to the following:
Python 3.14.2 (main, Dec 6 2025, 11:21:58) [GCC 14.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.15.0 -- An enhanced Interactive Python. Type '?' for help.
Welcome to isyside!
This is an interactive Python shell with the loaded model accessible as model.
Builtin modules: syside
Convenience variables: model, diagnostics
The shell brings in syside alone, so import the query package first, then count the parts in the model:
In [1]: from syside import query
In [2]: len(query.find_elements_of_type(model, syside.PartUsage))
Out[2]: 7
That is the 7 parts in the model. Counting part definitions takes a slightly different command:
In [3]: len(query.find_elements_of_type(model, syside.PartDefinition))
Out[3]: 2
You could also use the same idea to count ActionUsage,
etc.
Complex commands
Interactive mode works the same way as the Python API, so you can use the same functions and methods. However, sometimes you might need more than a single line of code to do something.
For example, list every part definition in the model:
In [4]: for element in query.find_elements_of_type(model, syside.PartDefinition):
...: print(element.name if element.name else "anonymous")
...:
Electrical
Mechanical
Interactive mode will recognize when an extra line of code is needed (in this case - to define the for loop) and will prompt you to continue. To complete this loop, simply press Enter after inputting an empty line.
Once you are done using interactive mode, you can exit by typing exit and
pressing Enter.