Skip to content

Latest commit

 

History

History
97 lines (74 loc) · 3.21 KB

File metadata and controls

97 lines (74 loc) · 3.21 KB

opensysml

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.

Install

Python 3.10 or later is required. Install the published package from PyPI:

pip install opensysml

The runtime dependencies are grpcio>=1.83.0, protobuf>=7.35.1 and sigstore>=4.5.0,<5.

A development snapshot of the client is published every night as opensysml==<next release>.dev<yyyymmdd>, which pip install opensysml never picks up; install one by exact version. It starts the sysml-grpc of the same night's snapshot, whose digests it pins. See Nightly snapshots.

Quickstart

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 service

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:

  1. $OPENSYSML_BINARY, if set.
  2. The shared cache at ~/.opensysml/bin/sysml-grpc.
  3. A download of the OpenSysML release this package was built against.
  4. A sysml-grpc on $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.

Documentation

To install from a checkout, run tests, regenerate protobufs or pin release digests, see DEVELOPING.md.