opensysml is the Python client for the OpenSysML SysML v2 parser, model
analysis and execution service. Load SysML models, inspect symbols and
diagnostics, evaluate values, verify constraints, run behaviors, edit source,
and query model documents from Python.
Python 3.10 or later is required. Install the published package from PyPI:
pip install opensysmlThe runtime dependencies are grpcio>=1.83.0, protobuf>=7.35.1 and
sigstore>=4.5.0,<5.
import opensysml
source = """\
package Demo {
part def Vehicle {
attribute mass default = 1500.0;
}
part sedan : Vehicle {
attribute :>> mass = 1800.0;
}
}
"""
model = opensysml.loads(source)
if not model.ok:
for diagnostic in model.diagnostics:
print(diagnostic)
raise SystemExit("The model has errors.")
print(model.eval("mass", subject="Demo::sedan"))1800.0
The client talks to a sysml-grpc service. You do not have to install or
start one: the first connection starts a private service for the current
interpreter and stops it when the interpreter exits.
To find the service binary, the client checks, in order:
$OPENSYSML_BINARY, if set.- The shared cache at
~/.opensysml/bin/sysml-grpc. - A download of the OpenSysML release this package was built against.
- A
sysml-grpcon$PATH.
A downloaded binary is verified against a SHA-256 digest shipped inside the
package, so a normal pip install opensysml followed by opensysml.connect()
needs no environment variables and no extra setup. Downloading another release
is also verified, through its signed checksum manifest; an unverifiable download
is refused rather than trusted.
To use a service you run yourself, pass its address:
model = opensysml.connect("localhost:50051").load("model.sysml")The service guide covers the cache, offline use, trust configuration and connecting to an external service.
- Python client guide
- Models and symbols
- Instances and values
- Verification and analysis
- Editing and saving
- Queries and documents
- Errors
- The service
- Typed classes
- API reference
To install from a checkout, run tests, regenerate protobufs or pin release digests, see DEVELOPING.md.