Skip to content

The Python API reference

This page documents every name exported by opensysml.__all__, grouped by the module that defines it. For task-oriented help, see Python client guides: models and symbols, instances and values, verification and analysis, editing and saving, queries and documents, errors, the service and typed classes.

opensysml

Top-level constants and functions for loading, evaluating, converting and connecting to models.

opensysml.FORMAT_API_JSON module-attribute

FORMAT_API_JSON = 'api-json'

opensysml.FORMAT_SYSML module-attribute

FORMAT_SYSML = 'sysml'

opensysml.FORMAT_TURTLE module-attribute

FORMAT_TURTLE = 'ttl'

opensysml.CAPABILITY_CONSTRAINT_BODY_AUTHORING module-attribute

CAPABILITY_CONSTRAINT_BODY_AUTHORING = 'constraint_body_authoring'

opensysml.CAPABILITY_STATE_ACTION_AUTHORING module-attribute

CAPABILITY_STATE_ACTION_AUTHORING = 'state_action_authoring'

opensysml.CAPABILITY_BIG_INT_VALUES module-attribute

CAPABILITY_BIG_INT_VALUES = 'big_int_values'

opensysml.CAPABILITY_RATIONAL_VALUES module-attribute

CAPABILITY_RATIONAL_VALUES = 'rational_values'

opensysml.CAPABILITY_CONVERT_DOCUMENTS module-attribute

CAPABILITY_CONVERT_DOCUMENTS = 'convert_documents'

opensysml.CAPABILITY_CONVERT_COMPACT module-attribute

CAPABILITY_CONVERT_COMPACT = 'convert_compact'

opensysml.CAPABILITY_PARSE_SOURCES_AFFECTED module-attribute

CAPABILITY_PARSE_SOURCES_AFFECTED = 'parse_sources_affected'

opensysml.load

load(file_path, host='localhost', port=None, strict=False, strict_conformance=False)

Load a SysML model from a .sysml, .kerml, or API element-form .json file.

Convenience function that uses a module-level singleton connection.

Parameters:

Name Type Description Default
file_path str

Path to .sysml file

required
host str

Service hostname, or a host:port address

'localhost'
port int

Service port (default: 50051)

None
strict bool

Refuse a model the service reported errors for, rather than returning one whose lookups fail later

False
strict_conformance bool

Ask whether the file is conforming SysML v2: notation only OpenSysML accepts is an error, not a warning

False

Returns:

Name Type Description
Model

Parsed model object

Raises:

Type Description
ModelFileNotFoundError

If the service cannot read file_path

ModelError

If strict and the model has error diagnostics

ConnectionError

If the service is unreachable

ValueError

If host names a port that is unreadable or disagrees with port

opensysml.loads

loads(content, host='localhost', port=None, language=None, strict=False, strict_conformance=False)

Parse inline SysML or KerML content using the default connection.

opensysml.read_json

read_json(source: str | PathLike[str] | bytes | bytearray | memoryview | Sequence[Mapping[str, Any]] | Mapping[str, Any], *, supertypes: Mapping[str, str] | None = None, check_ranges: bool = True) -> ElementGraph

Read an exported JSON document; strings and paths name files, not JSON text.

opensysml.parse_sources

parse_sources(documents, host='localhost', port=None, strict=False, strict_conformance=False)

Parse several documents as one model using the default connection.

Each document is a path, a (name, content) pair of inline source, or a SourceDocument; an import from one document into another resolves and diagnostics name the document they came from. See Connection.parse_sources.

Parameters:

Name Type Description Default
documents Sequence

The documents, in order

required
host str

Service hostname, or a host:port address

'localhost'
port int

Service port (default: 50051)

None
strict bool

Refuse a model the service reported errors for, rather than returning one whose lookups fail later

False
strict_conformance bool

Ask whether the documents are conforming SysML v2: notation only OpenSysML accepts is an error, not a warning

False

Returns:

Name Type Description
Model

The model of all the documents

Raises:

Type Description
ValueError

If there are no documents or two share a name

MissingCapabilityError

If the service predates parse_sources

ModelFileNotFoundError

If the service cannot read a file

ModelError

If the documents could not be parsed as a model, or if strict and the model has error diagnostics

ConnectionError

If the service is unreachable

opensysml.connect

connect(host='localhost', port=None, auto_start=True, version=None, require_capabilities=None)

Create a new connection to sysml-grpc service.

Convenience function that creates a new Connection instance.

Parameters:

Name Type Description Default
host str

Hostname of an externally managed service, or a host:port address naming one. Naming either connects to a service this client does not manage; unnamed, and with $OPENSYSML_SERVICE unset, a private service is used instead (default: 'localhost')

'localhost'
port int

Port of an externally managed service

None
auto_start bool

If True, start a private service when no address is named. If False, start nothing (default: True)

True
version str

Release tag the service must report, or 'latest'; defaults to $OPENSYSML_GRPC_VERSION. Checked whether the service is private or externally managed

None
require_capabilities iterable

Capability names the service must report, checked at connect time

None

Returns:

Name Type Description
Connection

New connection instance

Raises:

Type Description
ValueError

If host names a port that is unreadable or disagrees with port

ConnectionError

If a private service cannot be started

StaleServiceError

If the service reached is another release

MissingCapabilityError

If the service lacks a required capability

Example

conn = opensysml.connect("localhost:50123") conn.port 50123

opensysml.convert

convert(to_format, file_path=None, content=None, model_hash=None, from_format='', tolerate_syntax_errors=False, host='localhost', port=None)

Write a model out in another format (module-level convenience).

Parameters:

Name Type Description Default
to_format str

'sysml', 'kerml', 'text', 'ttl', 'turtle', 'rdf', 'api-json' or 'json'

required
file_path str

Path the service reads the source from

None
content str

Source carried inline

None
model_hash str

Hash of a loaded model, whose parsed source is converted

None
from_format str

Format to read the source as, one of the to_format names; inferred from file_path's extension when omitted, notation for a model_hash, and required for inline content. A SysML v1 model ('xmi', 'uml', 'mdzip') is refused: it is migrated by migrate, not converted

''
tolerate_syntax_errors bool

Write notation back out even when the parser could not read all of it

False
host str

Service hostname, or a host:port address

'localhost'
port int

Service port (default: 50051)

None

Returns:

Name Type Description
Conversion

The converted model; str() of it is the text

Warns:

Type Description
ExperimentalFeatureWarning

If either format is RDF, whose mapping is experimental (see docs/reference/rdf-mapping.md)

Example

import opensysml turtle = opensysml.convert("ttl", file_path="model.sysml") turtle.write("model.ttl") 'model.ttl'

opensysml.migrate

migrate(to_format, file_path=None, content=None, from_format='', report=False, results=False, layout_path=None, layout_content=None, image_base_url='', strict=False, host='localhost', port=None)

Migrate a SysML v1 model to SysML v2 (module-level convenience).

Migration is ledgered, not lossless: every element comes back in the result's report as mapped, approximated, unmapped or skipped. This is what sysml Model.mdzip -migrate sysml -migration-report Model.report.txt does.

Parameters:

Name Type Description Default
to_format str

'sysml', 'kerml', 'text', 'ttl', 'turtle', 'rdf', 'api-json' or 'json'

required
file_path str

Path the service reads the v1 model from

None
content bytes

The v1 model carried inline, as bytes

None
from_format str

'xmi', 'uml' or 'mdzip'; inferred from file_path's extension when omitted, required for inline content

''
report bool

Ask for every element's verdict and the report text

False
results bool

Ask for the JSON index of the v1 tool's stored results

False
layout_path str

MTIP export to lay the migrated views out from

None
layout_content str

The MTIP export carried inline

None
image_base_url str

URL the model refers to its image files under

''
strict bool

Write only standard notation, as -strict

False
host str

Service hostname, or a host:port address

'localhost'
port int

Service port (default: 50051)

None

Returns:

Name Type Description
Migration

The migrated model and its report; str() of it is the text

Warns:

Type Description
ExperimentalFeatureWarning

Always; the migration is experimental (see docs/reference/sysml-v1-migration.md)

Example

import opensysml migrated = opensysml.migrate("sysml", file_path="Vehicle.mdzip", report=True) migrated.report.summary 'migrated 93 element(s): 78 mapped, 12 approximated, 3 unmapped (...)' migrated.write("Vehicle.sysml") 'Vehicle.sysml'

opensysml.evaluate

evaluate(expression, file_path=None, model_hash=None, context_symbol_id=None, host='localhost', port=None, subject=None)

Evaluate a SysML expression (module-level convenience).

A model in hand has Model.eval, which needs neither the hash nor the connection; this form is for an expression evaluated against a file.

Parameters:

Name Type Description Default
expression str

SysML expression

required
file_path str

Parse this file first, get model_hash

None
model_hash str

Use existing model hash

None
context_symbol_id str

Context for evaluation

None
host str

Service hostname, or a host:port address

'localhost'
port int

Service port (default: 50051)

None
subject str

FQN of a part/usage to instantiate and evaluate against, so a feature reads that object's value rather than the declared default. Last, so a positional call written before it still binds the address it meant

None

Returns:

Type Description

Evaluated value

Raises:

Type Description
ValueError

If neither file_path nor model_hash provided, if both are, or if host names a port that is unreadable or disagrees with port

ExecutionError

If evaluation fails

Example

import opensysml result = opensysml.evaluate("2 + 2", file_path="test.sysml") print(result) # 4

opensysml.instantiate

instantiate(symbol_id, file_path=None, model_hash=None, host='localhost', port=None)

Instantiate a part/usage (module-level convenience).

A model in hand has Model.instantiate, which needs neither the hash nor the connection; this form is for instantiating out of a file.

Parameters:

Name Type Description Default
symbol_id str

FQN of symbol to instantiate

required
file_path str

Parse this file first

None
model_hash str

Use existing model hash

None
host str

Service hostname, or a host:port address

'localhost'
port int

Service port (default: 50051)

None

Returns:

Name Type Description
Instance

Instance object

Raises:

Type Description
ValueError

If neither file_path nor model_hash provided, if both are, or if host names a port that is unreadable or disagrees with port

ExecutionError

If instantiation fails

Example

import opensysml instance = opensysml.instantiate("SPACECRAFT_WET", file_path="A1.sysml") print(instance.id)

opensysml.DEFAULT_PORT module-attribute

DEFAULT_PORT = 50051

opensysml.__version__ module-attribute

__version__ = _declared_version

Metamodel classes and the JSON reader

opensysml.generate creates classes for definitions in a user's SysML model. The separate opensysml.metamodel package contains generated classes for the SysML metamodel itself. Use opensysml.read_json to wrap an exported JSON document without starting a service:

import opensysml
from opensysml.metamodel import PartDefinition, PartUsage

graph = opensysml.read_json("vehicle.json")
vehicle = next(
    definition for definition in graph.all(PartDefinition)
    if definition.declared_name == "Vehicle"
)
print([feature.declared_name for feature in vehicle.owned_feature])
for part in graph.all(PartUsage):
    print(part.declared_name)

Elements use the metaclass inheritance hierarchy, so isinstance(part, Feature) works. Property names use snake_case primarily (owned_feature) and expose their SysML camelCase spelling as an alias (ownedFeature) to the same descriptor. PartUsage.from_json_key("partDefinition") returns the primary Python name, and PartUsage.json_key("part_definition") returns the JSON key. Strings passed to read_json are file paths, not JSON text; bytes, mappings, and sequences of element mappings are also accepted. The reader understands DataVersion and Commit envelopes. Reference targets are checked against their declared metaclass ranges by default; pass check_ranges=False to return out-of-range targets as written.

Missing keys raise NotSupplied, including absent multi-valued properties. Dangling @id and unresolved @ref values raise UnresolvedReference when accessed. Invalid document structure raises MalformedDocument, and a value outside its declared type raises MalformedValue. These exceptions share MetamodelError, a subclass of opensysml.errors.OpenSysMLError:

Error Raised when
NotSupplied A declared JSON key is absent; .derived identifies computed properties.
UnresolvedReference A reference's @id is absent from the graph or its @ref cannot be resolved.
MalformedValue A property value has the wrong primitive, enum, array, or reference shape, or (when range checks are enabled) a reference targets the wrong metaclass.
MalformedDocument The input is not an element object/array, or has missing/duplicate IDs or types.
UnknownJSONKey A JSON key is not declared for the selected metaclass.

OpenSysML's api-json export carries the owned properties it writes plus some derived ones (ownedFeature, owner, qualifiedName, ownedMember, ...). It carries no feature, inheritedFeature or definition, and type only on some usages, so those reads raise NotSupplied with derived=True until the engine serves derived properties. The export also writes no null and no []: an unset owned property, such as an unnamed element's declaredName, is absent and raises NotSupplied too. sysml-toolkit full-json carries derived properties as well. A reference to an element the document does not include, such as a standard-library element, raises UnresolvedReference when read. Providing engine-computed derived properties, implementing metamodel operations, and loading JSON into the OpenSysML engine are separate follow-up work.

opensysml.connection

Connections own or reach a service, and resolve their address and release.

opensysml.Connection

Manages connection to sysml-grpc service.

Unless an address is named, a connection joins this interpreter's private service, starting it if there is none: a child on a port the kernel chose, which no other process can reach and which dies with this one.

Attributes:

Name Type Description
host str

Service hostname

port int

Service port

close

close()

Close the gRPC channel and release any hold on a private service.

server_info

server_info()

Ask the service what it is and what it supports.

The answer is cached for the life of the connection: a service does not change build while a channel is open to it.

Returns:

Name Type Description
ServerInfo

Reported version and capabilities. answered is False when the service predates the GetServerInfo RPC, in which case it claims no capabilities.

Raises:

Type Description
StaleServiceError

If a release was asked for and this first answer shows the service is another one

load

load(file_path, strict=False, strict_conformance=False)

Load a SysML model from file.

Parameters:

Name Type Description Default
file_path str

Path to .sysml file

required
strict bool

Refuse a model the service reported errors for, instead of returning one whose lookups fail later. The ModelError raised carries the model, so its diagnostics stay inspectable.

False
strict_conformance bool

Ask whether the file is conforming SysML v2: notation only OpenSysML accepts is reported as an error rather than a warning.

False

Returns:

Name Type Description
Model

Parsed model object

Raises:

Type Description
ModelFileNotFoundError

If the service cannot read file_path

ModelError

If strict and the model has error diagnostics

ServiceError

If the service fails the call for any other reason

load_from_content

load_from_content(content, strict=False, language=None, strict_conformance=False)

Load a model from inline SysML content.

Parameters:

Name Type Description Default
content str

SysML source code

required
strict bool

Refuse a model the service reported errors for

False
language str

"sysml" or "kerml"; the language the inline content is written in

None
strict_conformance bool

Ask whether the content is conforming SysML v2: notation only OpenSysML accepts is an error, not a warning

False

Returns:

Name Type Description
Model

Parsed model object

Raises:

Type Description
ModelError

If strict and the model has error diagnostics

parse_sources

parse_sources(documents, strict=False, strict_conformance=False)

Parse several documents together as one model.

An import from one document into another resolves, and each diagnostic names the document it came from, so a model written as several files (chapters importing earlier chapters) is loaded as it stands rather than concatenated into one string. Files are read on the machine the service runs on, as load reads them.

Parameters:

Name Type Description Default
documents Sequence

The documents, in order. Each is a path (str or os.PathLike) to a .sysml or .kerml file, a (name, content) pair of inline source reported under that name, or a SourceDocument, which is also how inline content is declared to be KerML. Two documents may not share a name.

required
strict bool

Refuse a model the service reported errors for, instead of returning one whose lookups fail later. The ModelError raised carries the model, so its diagnostics stay inspectable.

False
strict_conformance bool

Ask whether the documents are conforming SysML v2: notation only OpenSysML accepts is reported as an error rather than a warning.

False

Returns:

Name Type Description
Model

The model of all the documents, with one root per document

in Model.roots (the first as Model.root) and their

names in Model.documents

Raises:

Type Description
ValueError

If there are no documents, two share a name, or one is of none of the accepted forms

MissingCapabilityError

If the service predates parse_sources, or strict_conformance/inline_language when asked for

ModelFileNotFoundError

If the service cannot read a file

InvalidRequestError

If the service refuses the documents

ModelError

If the service could not parse the documents as a model, or if strict and the model has error diagnostics

ServiceError

If the service fails the call for any other reason

Example

model = conn.parse_sources([ ... ("lib.sysml", "package Lib { part def Engine; }"), ... ("top.sysml", "package Top { import Lib::*; part def Car { part e : Engine; } }"), ... ]) model.ok True model["Lib::Engine"].name 'Engine' model.documents ('lib.sysml', 'top.sysml')

convert

convert(to_format, file_path=None, content=None, model_hash=None, from_format='', tolerate_syntax_errors=False)

Write a model out in another of the formats OpenSysML writes.

The source is a loaded model, named by its hash, or one named the way load names it: a path the service opens, or content carried inline. A hash converts the source the service parsed, so a file edited since the load does not change the answer; a path is read afresh.

Parameters:

Name Type Description Default
to_format str

Format to write: 'sysml', 'kerml', 'text', 'ttl', 'turtle', 'rdf', 'api-json' or 'json'

required
file_path str

Path the service reads the source from

None
content str

Source carried inline

None
model_hash str

Hash of a loaded model, whose parsed source is converted

None
from_format str

Format to read the source as, one of the to_format names; inferred from file_path's extension when omitted, notation for a model_hash, and required for inline content

''
tolerate_syntax_errors bool

Write notation back out even when the parser could not read all of it, reporting its syntax errors as the result's diagnostics. Notation to notation only: every other direction builds a graph, where unreadable declarations would go missing silently.

False

A SysML v1 model — from_format of 'xmi', 'uml' or 'mdzip', or a file_path with that extension — is refused: it is migrated, not converted, and migrate accounts for every element on the way.

Returns:

Name Type Description
Conversion

The converted model, the formats used and any tolerated syntax errors

Warns:

Type Description
ExperimentalFeatureWarning

If either format is RDF, whose mapping is experimental (see docs/reference/rdf-mapping.md)

Raises:

Type Description
ValueError

If other than one of file_path, content and model_hash is given

InvalidRequestError

If the source is a SysML v1 model, with the help that names migrate; also if a format is unknown

MissingCapabilityError

If the service cannot convert

ConversionError

If the model could not be written in that format

ModelFileNotFoundError

If the named file cannot be read

ModelNotFoundError

If the model is no longer cached

migrate

migrate(to_format, file_path=None, content=None, from_format='', report=False, results=False, layout_path=None, layout_content=None, image_base_url='', strict=False)

Migrate a SysML v1 model to SysML v2, accounting for every element.

The source is UML XMI, an Eclipse UML2 .uml file or a Cameo/MagicDraw .mdzip archive, named by a path the service opens or carried inline as bytes. Migration is ledgered, not lossless: every element comes back in the MigrationReport as mapped, approximated, unmapped or skipped, and the summary and counts come with every answer. This is what sysml Model.mdzip -migrate sysml does.

Parameters:

Name Type Description Default
to_format str

Format to write: 'sysml', 'kerml', 'text', 'ttl', 'turtle', 'rdf', 'api-json' or 'json'

required
file_path str

Path the service reads the v1 model from

None
content bytes

The v1 model carried inline — bytes, since an .mdzip archive is binary

None
from_format str

'xmi', 'uml' or 'mdzip'; inferred from file_path's extension when omitted, and required for inline content

''
report bool

Ask for every element's verdict and the report text -migration-report writes, not just the summary and counts

False
results bool

Ask for the JSON index of the result snapshots the v1 tool stored, as -migration-results writes it

False
layout_path str

Path to an MTIP export whose diagram layouts the migrated views are laid out from, as -layout

None
layout_content str

The MTIP export carried inline

None
image_base_url str

URL the migrated model refers to its image files under, instead of the relative images/ paths

''
strict bool

Write only standard notation, leaving an element whose only v2 form is an OpenSysML extension unmapped, as -strict

False

Returns:

Name Type Description
Migration

The migrated model, its report, and the results and image files asked for

Warns:

Type Description
ExperimentalFeatureWarning

Always: the migration is experimental (see docs/reference/sysml-v1-migration.md)

Raises:

Type Description
ValueError

If other than one of file_path and content is given, or both layout_path and layout_content

InvalidRequestError

If the source is not a SysML v1 model — that is converted, not migrated — or a format is unknown, or the layout is not an MTIP export

MissingCapabilityError

If the service cannot migrate

MigrationError

If the v1 model could not be read

ModelFileNotFoundError

If the named file cannot be read

apply_edits

apply_edits(model_hash, operations)

Apply source-preserving edits to a loaded model.

The operations are performed on the source the service parsed, so what comes back is that notation with the edited spans replaced and every other byte — comments, blank lines, indentation — unchanged. The service re-parses and re-analyses the result and refuses to return content the parser could not read back.

Parameters:

Name Type Description Default
model_hash str

Hash of the model to edit

required
operations list[tuple]

('set_value', target, value) and ('rename', target, new_name) tuples, as Editor collects them, along with ('add_connection', owner, kind, from_end, to_end, name, type) and ('add_sequence', owner, keyword, ref, member_kind, member_name, type, after), add-member tuples of 8, 12, 13, 14 or 15 fields; extended tuples carry modifiers, metadata prefixes, a constraint body_expression and optional documentation text. It also accepts ('add_import', owner, visibility, target, recursive, import_all, filters) and ('add_documentation', target, body, name, locale, replace), ('add_comment', owner, body, name, about, locale) (about a list or tuple of names) and ('add_note', target, text)

required

Returns:

Name Type Description
EditResult

The edited notation and what each operation changed

Raises:

Type Description
ValueError

If an operation names no kind this client knows

EditError

If the service refused the edit; the subclass names why, including NoEditsError for no operations at all

MissingCapabilityError

If the service cannot apply edits

ModelNotFoundError

If the model is no longer cached

query

query(model_hash, payload=None, scope=None, select=None, where=None)

Run a SysML v2 API & Services Query over a loaded model.

The query is the standard's JSON object, so a cookbook payload works verbatim, or the same thing as keywords. See opensysml.query.

Parameters:

Name Type Description Default
model_hash str

Hash of the model to query

required
payload dict

The standard's Query object

None
scope list

Elements to consider; empty is the whole model

None
select list

Properties to report; empty reports every one

None
where dict

Constraint to filter by

None

Returns:

Type Description

list[QueryElement]: The elements selected, in declaration order

Raises:

Type Description
QueryError

If the query is not one the standard's model describes

MissingCapabilityError

If the service cannot query

InvalidRequestError

If a property or scope is unknown to the service

ModelNotFoundError

If the model is no longer cached

run_document_query

run_document_query(model_hash, query_id, bindings=None)

Run a named document query and answer its typed rows.

The query is the model's own — a calc def specializing DocumentQueries::Query — not the standard's Query object that query evaluates. See opensysml.document.

Parameters:

Name Type Description Default
model_hash str

Hash of the model holding the query

required
query_id str

Qualified name of the document query

required
bindings Mapping

Parameter name to a value or list of values; an ElementRef binds a model element, an ObjectRef an object instantiate built, by id or by path

None

Returns:

Name Type Description
DocumentQueryResult

Projected columns and typed rows, in the

engine's deterministic order

Raises:

Type Description
MissingCapabilityError

If the service cannot run document queries

InvalidRequestError

If the query is not one, or a binding is wrong

SymbolNotFoundError

If the model does not declare the query, or an object binding names an object the model does not hold

ModelNotFoundError

If the model is no longer cached

render_document

render_document(model_hash, document_id, form='markdown')

Render a named document to Markdown or HTML.

The document is the model's own — a part def specializing DocumentQueries::Document — whose queries are bound in the model.

Parameters:

Name Type Description Default
model_hash str

Hash of the model holding the document

required
document_id str

Qualified name of the document

required
form str

"markdown" (the default) or "html", the standalone page with the default stylesheet that the CLI's -doc-form html writes

'markdown'

Returns:

Name Type Description
str

The rendered document in the form asked for

Raises:

Type Description
ValueError

If form is neither "markdown" nor "html"

MissingCapabilityError

If the service cannot render documents, or cannot render HTML when that form is asked for

InvalidRequestError

If the symbol named is not a document

SymbolNotFoundError

If the model does not declare the document

ModelNotFoundError

If the model is no longer cached

render_view

render_view(model_hash, view_name, ports='minimal')

Render a named view with minimal or full ports.

export_graphs

export_graphs(model_hash, subject)

Export the lowered graph of an action or state machine as graphs:1 JSON.

get_symbol

get_symbol(model_hash, symbol_id)

Fetch symbol by ID from cached model.

Parameters:

Name Type Description Default
model_hash str

Model content hash

required
symbol_id str

Fully-qualified symbol ID

required

Returns:

Type Description

sysml_pb2.SymbolInfo or None: Symbol protobuf, or None if not found

eval

eval(expression, model_hash, context_symbol_id=None, subject_symbol_id=None)

Evaluate a SysML expression.

Parameters:

Name Type Description Default
expression str

SysML expression (e.g., "2 + 2")

required
model_hash str

Hash from ParseFile response

required
context_symbol_id str

Symbol FQN for context scope

None
subject_symbol_id str

FQN of a part/usage to instantiate and evaluate against, so a feature reads that object's value rather than the declared default

None

Returns:

Type Description

Value from expression (int, float, bool, str, Instance, etc.)

Raises:

Type Description
ExecutionError

If evaluation fails

ModelNotFoundError

If the service no longer holds the model

UnsupportedValueError

If the result cannot be represented on the wire

instantiate

instantiate(symbol_id, model_hash)

Instantiate a part/usage symbol.

Parameters:

Name Type Description Default
symbol_id str

FQN of part/usage to instantiate

required
model_hash str

Hash from ParseFile response

required

Returns:

Type Description

Instance object

Raises:

Type Description
ExecutionError

If instantiation fails

ModelNotFoundError

If the service no longer holds the model

MissingCapabilityError

If the service predates feature_values

execute_action

execute_action(action_symbol_id, model_hash, inputs=None, schedule=None, performer=None)

Execute an action definition.

Parameters:

Name Type Description Default
action_symbol_id str

FQN of action def

required
model_hash str

Hash from ParseFile response

required
inputs dict

Input parameter name → value

None
schedule str

Scheduling policy the run resolves its choice points under — "declared", "reverse" (the default) or "seed:<n>" — spelled as sysml -schedule spells it. "explore" answers with every outcome rather than one run's, so it belongs to explore_action

None
performer str

The object the action runs on, as sysml -action "<action> <object>" names it: a part definition or usage to make an object of, or a path from one into its parts ("Mission::mission.vehicle") — the mission is made and the action performed by its vehicle, inside the assembly, so what its siblings send over their connectors reaches it. Without one the action runs outside any object

None

Returns:

Name Type Description
ActionOutputs

Output parameter name → value, a dict; an output the wire format cannot represent is reported as an UnsupportedValueError in its place, so one such output does not discard the rest. Its performer holds the performer's attributes as the run left them under this. ('this.level'), as an explored outcome's outputs spell them; empty without a performer

Raises:

Type Description
ValueError

If the schedule explores

ExecutionError

If execution fails

ModelNotFoundError

If the service no longer holds the model

MissingCapabilityError

If an input holds a complex and the service predates complex_values, an Array, Vector or VectorQuantity and the service predates structured_values, a MeasurementRef and the service predates measurement_refs, a Function and the service predates function_values, a SetValue and the service predates set_values, a TensorQuantity and the service predates tensor_values, a Metaobject and the service predates metaobject_values, a schedule is given and the service predates schedule, or a performer is given and the service predates performer; nothing is sent

InvalidRequestError

If the schedule names no policy

explore_action

explore_action(action_symbol_id, model_hash, inputs=None, schedule='explore', performer=None)

Run an action once per valid order of its choice points, within a budget.

The service replays the action from the start, taking a different alternative at some choice point each time, until every order within the budget has run. Runs agreeing on their outputs are one outcome; a run that failed is an outcome of its own rather than an error of the exploration.

Parameters:

Name Type Description Default
action_symbol_id str

FQN of action def

required
model_hash str

Hash from ParseFile response

required
inputs dict

Input parameter name → value

None
schedule str

"explore" or "explore:runs=<n>,depth=<d>", bounding the runs made and the choice points one run resolves; the service documents the defaults

'explore'
performer str

The object the action runs on, as for execute_action; every explored run makes it anew

None

Returns:

Name Type Description
Exploration

Every distinct outcome reached and how the exploration ended; incomplete, naming the budget, when a budget was hit

Raises:

Type Description
ValueError

If the schedule does not explore

ExecutionError

If the action could not be explored at all — an unknown action, an input of the wrong kind

ModelNotFoundError

If the service no longer holds the model

MissingCapabilityError

If the service predates schedule_explore, or performer when a performer is given, or an input needs a value capability it lacks; nothing is sent

InvalidRequestError

If the schedule's options are malformed

execute_state

execute_state(state_machine_symbol_id, model_hash, events=None, schedule=None, performer=None, trace=False)

Execute a state machine.

Parameters:

Name Type Description Default
state_machine_symbol_id str

FQN of state machine def

required
model_hash str

Hash from ParseFile response

required
events list

Event names to process

None
schedule str

Scheduling policy the run resolves its choice points under, as for execute_action; "explore" belongs to explore_state

None
performer str

The object the machine runs on, as for execute_action: a part definition or usage, or a path from one into its parts. An object exhibiting the machine runs the machine it exhibits, so its transitions hear what the object's siblings send over their connectors

None
trace bool

Whether to return the run's typed execution trace; requires the state_trace capability

False

Returns:

Name Type Description
dict

{'states_visited': [...], 'final_context': {...}, 'final_time': float, 'trace': [DocumentEvent, ...], 'trace_dropped': int}; a context value the wire format cannot represent is reported as an UnsupportedValueError in its place; final_time is the run's simulation clock when it ended, in seconds, the instant of its last time-triggered transition — 0.0 from a service that predates final_time

Raises:

Type Description
ValueError

If the schedule explores

ExecutionError

If execution fails

ModelNotFoundError

If the service no longer holds the model

MissingCapabilityError

If a schedule is given and the service predates schedule, a performer is given and the service predates performer, or trace is requested and it predates state_trace; nothing is sent

InvalidRequestError

If the schedule names no policy

explore_state

explore_state(state_machine_symbol_id, model_hash, events=None, schedule='explore', performer=None)

Run a state machine over the events once per valid order of its choice points.

Runs agreeing on the state they rest in, the states they entered and the values they hold are one outcome; see explore_action.

Parameters:

Name Type Description Default
state_machine_symbol_id str

FQN of state machine def

required
model_hash str

Hash from ParseFile response

required
events list

Event names to process

None
schedule str

"explore" or "explore:runs=<n>,depth=<d>"

'explore'
performer str

The object the machine runs on, as for execute_state; every explored run makes it anew

None

Returns:

Name Type Description
Exploration

Every distinct outcome reached and how the exploration ended

Raises:

Type Description
ValueError

If the schedule does not explore

ExecutionError

If the machine could not be explored at all

ModelNotFoundError

If the service no longer holds the model

MissingCapabilityError

If the service predates schedule_explore, or performer when a performer is given; nothing is sent

InvalidRequestError

If the schedule's options are malformed

list_engines

list_engines()

List the analysis engines the service answers with, as sysml -engines does.

Returns:

Type Description

list[EngineInfo]: One per engine, in name order, with the strength it may claim, the questions it answers and whether it can run

Raises:

Type Description
MissingCapabilityError

If the service predates engines; nothing is sent

verify_constraint

verify_constraint(symbol_id, model_hash, subject_symbol_id=None, engine=None, question=None)

Ask whether a constraint holds, as the REPL's %constraint does.

Parameters:

Name Type Description Default
symbol_id str

FQN of the constraint definition or usage

required
model_hash str

Hash from ParseFile response

required
subject_symbol_id str

FQN of a part/usage to instantiate and evaluate against, so the verdict is about concrete values rather than declared defaults

None
engine str

The engine to ask, as sysml -engine spells it: "auto" (the default) for the strongest covering engine, "all" for every covering one composed, or one by name, whose refusal is then the answer

None
question str

The question to ask: "evaluate" (the default), "holds" whether the claim holds for every assignment the free features can take, or "satisfiable" whether any assignment satisfies it. The verdict's status says which answer was proved; witness carries the free features' values when the answer is violated or satisfiable, and error says why nothing was decided otherwise

None

Returns:

Name Type Description
Verdict

The answer. A condition that evaluated to false is that answer, not an exception; a failure to evaluate is reported as verdict.error.

Raises:

Type Description
WrongKindError

If symbol_id names an element that is not a constraint, which is a wrong request rather than a verdict

ExecutionError

If the request could not be answered at all — an unknown symbol, a subject that could not be instantiated

MissingCapabilityError

If the service cannot verify, an engine is given and the service predates engines, or a question other than "evaluate" is given and the service predates verification_questions; nothing is sent

InvalidRequestError

If the engine names none the service registers

ModelNotFoundError

If the service no longer holds the model

verify_requirement

verify_requirement(symbol_id, model_hash, subject_symbol_id=None, engine=None, question=None)

Ask whether a requirement is satisfied, as %requirement does.

Parameters:

Name Type Description Default
symbol_id str

FQN of the requirement definition or usage

required
model_hash str

Hash from ParseFile response

required
subject_symbol_id str

FQN of a part/usage to instantiate and evaluate against

None
engine str

The engine to ask, as for verify_constraint

None
question str

The question to ask, as for verify_constraint

None

Returns:

Name Type Description
Verdict

The answer

Raises:

Type Description
WrongKindError

If symbol_id names an element that is not a requirement

ExecutionError

If the request could not be answered at all

MissingCapabilityError

If the service cannot verify, an engine is given and the service predates engines, or a question other than "evaluate" is given and the service predates verification_questions; nothing is sent

InvalidRequestError

If the engine names none the service registers

ModelNotFoundError

If the service no longer holds the model

verify_satisfaction

verify_satisfaction(model_hash, symbol_id=None, engine=None, question=None)

Ask whether the model's satisfaction assertions hold, as %satisfy does.

Each assertion is evaluated against an object of its subject, built for the call, so a verdict is about the values that subject holds.

Parameters:

Name Type Description Default
model_hash str

Hash from ParseFile response

required
symbol_id str

FQN limiting evaluation to the assertions stated within that element, or to that element itself when it is a named satisfaction assertion. Omitted evaluates every assertion the model states.

None
engine str

The engine to ask, as for verify_constraint

None
question str

The question to ask, as for verify_constraint

None

Returns:

Type Description

list[Verdict]: One verdict per assertion, in declaration order. A model stating no assertion gives an empty list. Each verdict's verifications are the cases verifying its own requirement, so a call covering several requirements does not mix them.

Raises:

Type Description
WrongKindError

If symbol_id names an element that can state no satisfaction assertion

ExecutionError

If the request could not be answered at all

MissingCapabilityError

If the service cannot verify, an engine is given and the service predates engines, or a question other than "evaluate" is given and the service predates verification_questions; nothing is sent

InvalidRequestError

If the engine names none the service registers

ModelNotFoundError

If the service no longer holds the model

validate_instance

validate_instance(symbol_id, model_hash, engine=None)

Check every assertion about an object and the objects it holds, as %validate does.

An object of the part named is built for the call, then each asserted constraint, each requirement and each satisfaction assertion whose subject lies in the object's tree is evaluated against the object carrying it — a wheel's constraint against each wheel, not against the car.

Parameters:

Name Type Description Default
symbol_id str

FQN of the part definition or usage an object of which is validated

required
model_hash str

Hash from ParseFile response

required
engine str

The engine to ask, as for verify_constraint

None

Returns:

Name Type Description
Validation

One verdict per assertion, naming the object it is about by its path from the root, and the object's own verdict. A failing assertion is that answer, not an exception; one that could not be evaluated is reported as its error.

Raises:

Type Description
ExecutionError

If the request could not be answered at all — an unknown symbol, or one no object can be built of

MissingCapabilityError

If the service cannot verify, or an engine is given and the service predates engines; nothing is sent

InvalidRequestError

If the engine names none the service registers

ModelNotFoundError

If the service no longer holds the model

calc

calc(symbol_id, model_hash, arguments=None, engine=None)

Invoke a calculation, as the REPL's %calc does.

Arguments are bound positionally. A calc usage named with no arguments binds its inputs from its own members and reports every output feature it computes (SysML 7.17).

Parameters:

Name Type Description Default
symbol_id str

FQN of the calc definition or usage

required
model_hash str

Hash from ParseFile response

required
arguments list

Positional arguments, as Python values

None
engine str

The engine to ask, as for verify_constraint

None

Returns:

Name Type Description
CalcResult

The value an invocation returned, or the output features a calc usage computed

Raises:

Type Description
WrongKindError

If symbol_id names an element that is not a calc

ExecutionError

If the calculation could not be evaluated

MissingCapabilityError

If the service cannot verify, or an argument holds a complex and the service predates complex_values, an array, vector or vector quantity and the service predates structured_values, a measurement reference and the service predates measurement_refs, a function and the service predates function_values, a set and the service predates set_values, a tensor quantity and the service predates tensor_values, a metaobject and the service predates metaobject_values, or an engine is given and the service predates engines; nothing is sent

InvalidRequestError

If the engine names none the service registers

ModelNotFoundError

If the service no longer holds the model

run_analysis

run_analysis(symbol_id, model_hash, subject=None, arguments=None, named_arguments=None, schedule=None, engine=None)

Run an analysis case, as the REPL's %analysis does.

The subject named is instantiated and bound as the case's subject; a usage that binds its own subject needs none. Positional arguments bind the case's in parameters in declaration order, the subject excluded; named arguments bind them by name. Its objective and each assert constraint in its body are then checked against what it computed (SysML 7.22).

Parameters:

Name Type Description Default
symbol_id str

FQN of the analysis case definition or usage

required
model_hash str

Hash from ParseFile response

required
subject str

FQN of a part/usage to instantiate and run the case on

None
arguments list

Positional arguments, as Python values

None
named_arguments dict

Arguments by parameter name

None
schedule str

Scheduling policy the actions the case performs resolve their choice points under, as for execute_action; "explore" belongs to explore_analysis

None
engine str

The engine to ask, as for verify_constraint; "explore" is the exploring schedule by another name and belongs to explore_analysis

None

Returns:

Name Type Description
AnalysisResult

The outputs the case computed and the verdict of its objective and assertions, with each evaluation a trade study made of an alternative

Raises:

Type Description
ValueError

If the schedule or the engine explores

WrongKindError

If symbol_id names an element that is not an analysis case

AnalysisRunError

If the case could not run to its end and left something to inspect — the evaluations made before an alternative failed, an objective the failure left undecided; carries it as result

ExecutionError

If the request was refused before the run — an unknown symbol — or the failure left nothing to report

MissingCapabilityError

If the service cannot verify, or an argument holds a complex and the service predates complex_values, an array, vector or vector quantity and the service predates structured_values, a set and the service predates set_values, a tensor quantity and the service predates tensor_values, a metaobject and the service predates metaobject_values, a schedule is given and the service predates schedule, or an engine is given and the service predates engines; nothing is sent

InvalidRequestError

If the schedule names no policy, or the engine names none the service registers

ModelNotFoundError

If the service no longer holds the model

explore_analysis

explore_analysis(symbol_id, model_hash, subject=None, arguments=None, named_arguments=None, schedule='explore')

Run an analysis case once per valid order of the choice points its actions meet.

Runs agreeing on the case's outputs and on its objective and assertion verdicts are one outcome; a verdict is reported among the outcome's outputs as objective <name> or assertion <name>, and what a verification case's body answered as verdict <case>. See explore_action.

Parameters:

Name Type Description Default
symbol_id str

FQN of the analysis case definition or usage

required
model_hash str

Hash from ParseFile response

required
subject str

FQN of a part/usage to instantiate and run the case on

None
arguments list

Positional arguments, as Python values

None
named_arguments dict

Arguments by parameter name

None
schedule str

"explore" or "explore:runs=<n>,depth=<d>"

'explore'

Returns:

Name Type Description
Exploration

Every distinct outcome reached and how the exploration ended

Raises:

Type Description
ValueError

If the schedule does not explore

WrongKindError

If symbol_id names an element that is not an analysis case

ExecutionError

If the case could not be explored at all — an unbound subject, an argument of the wrong kind

MissingCapabilityError

If the service cannot verify, predates schedule_explore or lacks a value capability an argument needs; nothing is sent

InvalidRequestError

If the schedule's options are malformed

ModelNotFoundError

If the service no longer holds the model

run_sweep

run_sweep(symbol_id, model_hash, ranges, subject=None, arguments=None, named_arguments=None, samples=0, seed=0, engine=None)

Run an analysis case or calc once per row of a parameter sweep.

Every row is an ordinary run of that target with the swept parameters bound to the row's values and the other arguments as given, so nothing about how one run executes changes. Several ranges make one row per point of their cartesian product, the first varying slowest. Passing samples draws that many rows uniformly from each range instead of stepping through it, in draw order, from seed: the same seed draws the same table. A run that failed is a row carrying its error.

Parameters:

Name Type Description Default
symbol_id str

FQN of the analysis case or calc

required
model_hash str

Hash from ParseFile response

required
ranges dict

Range per swept parameter, as {"speed": (0, 10, 2)} or {"speed": (0.0, 10.0)} where the rows are drawn; a range between whole numbers steps by one where it states no step, one with a fractional endpoint must state one; the values are typed by the parameter they bind

required
subject str

FQN of a part/usage to instantiate and run an analysis case on

None
arguments list

Positional arguments every row binds

None
named_arguments dict

Arguments by name every row binds

None
samples int

Rows to draw rather than step through

0
seed int

Seed the draws are taken from

0
engine str

The engine to ask, as for verify_constraint

None

Returns:

Name Type Description
SweepTable

One row per run, in the order the runs were made

Raises:

Type Description
WrongKindError

If symbol_id names neither an analysis case nor a calc

ExecutionError

If no run followed from the request — a parameter the target does not declare, a range no values follow from, a sample count of none, more runs than the service's budget, an engine that does not answer sweeps

MissingCapabilityError

If the service cannot verify, or an engine is given and the service predates engines; nothing is sent

InvalidRequestError

If the engine names none the service registers

ModelNotFoundError

If the service no longer holds the model

opensysml.split_target

split_target(host, port=None)

Split a host:port string written as the host into host and port.

connect("localhost:50123") names an address, not a hostname, so it is read as one rather than building localhost:50123:50051 and reporting the service unreachable at an address nobody asked for.

Parameters:

Name Type Description Default
host str

Hostname, or a host:port address

required
port int

Port; None is no port given, so an address's own port stands and a plain hostname gets DEFAULT_PORT

None

Returns:

Type Description

tuple[str, int]: The host and port to connect to

Raises:

Type Description
ValueError

If the address's port is not a number, or disagrees with a port also given

opensysml.model

A parsed model is the entry point for symbol lookup, evaluation and execution. Model.render_view(view_name, ports="minimal") returns a typed RenderedView; pass ports="full" to include every declared port. Model.export_graphs(subject) returns a typed Graphs: the canonical graphs:1 JSON of an action or state machine's lowered graph, its version and the subject as resolved.

opensysml.Model

Represents a parsed SysML model.

Attributes:

Name Type Description
hash str

Model content hash (for cache lookups)

root Symbol

Root symbol of the model; of a model parsed from several documents, the first document's

roots tuple[Symbol]

Root symbol of each document, in document order

documents tuple[str]

Name of each document as diagnostics report it

diagnostics list[Diagnostic]

Parse diagnostics (errors/warnings)

hash property

hash

Get model content hash.

connection property

connection

Get the connection this model was loaded over.

root property

root

Get root symbol.

A model parsed from several documents has one root per document; this is the first document's. roots has them all.

roots property

roots

Root symbol of each document, in document order.

A model loaded from one file or one string has one; a model of several documents (Connection.parse_sources) has one per document.

documents property

documents

Name of each document, in document order, as diagnostics report it.

A model of several documents names each by the path or name it was given; a model loaded from a file names that path; a model loaded from inline content has no name and this is empty.

diagnostics property

diagnostics

Get list of diagnostics.

errors property

errors

The error-severity diagnostics, which are what makes a model unusable.

Returns:

Type Description

list[Diagnostic]: Diagnostics of severity 'error', in report order

ok property

ok

Whether the service parsed and analysed this model without errors.

A model with errors is still returned and still navigable — that is how a tool reports every problem at once — but its symbols may be missing or unresolved, so lookups on it fail later. Test this, or load with strict=True, before treating a model as the model that was written.

Returns:

Name Type Description
bool

True when no diagnostic has error severity

source_path property

source_path

Path this model was loaded from, or None if it was loaded inline.

raise_for_errors

raise_for_errors()

Raise ModelError unless ok.

Returns:

Name Type Description
Model

self, so a call can be chained onto a load

Raises:

Type Description
ModelError

If the model has error diagnostics. It carries them as diagnostics and this model as model.

convert

convert(to_format, tolerate_syntax_errors=False)

Write this model out in one of the formats OpenSysML writes.

Converts the source this model was parsed from, not the file as it stands now, so what is written is the model that was inspected: notation keeps its comments and lexemes, re-indented, while Turtle carries what the model declares. See docs/reference/rdf-mapping.md.

The service holds that source in its model cache, which is bounded, so a model loaded long ago and many models back may have been evicted; load it again, or convert its path through Connection.convert.

Parameters:

Name Type Description Default
to_format str

'sysml', 'kerml', 'text', 'ttl', 'turtle', 'rdf', 'api-json' or 'json'

required
tolerate_syntax_errors bool

Write notation back out even when the parser could not read all of it

False

Returns:

Name Type Description
Conversion

The converted model; str() of it is the text

Warns:

Type Description
ExperimentalFeatureWarning

If the format is RDF, whose mapping is experimental — see docs/reference/rdf-mapping.md

Raises:

Type Description
ConversionError

If the model could not be written in that format

MissingCapabilityError

If the service cannot convert

RpcError

If the service no longer holds this model

to_sysml

to_sysml(tolerate_syntax_errors=False)

Write this model out as SysML textual notation.

Returns:

Name Type Description
Conversion

The notation; str() of it is the text

to_turtle

to_turtle()

Write this model out as an RDF graph in Turtle syntax.

The RDF mapping is experimental: it covers model structure and the behavior its bodies state, refuses what it cannot write back, and warns with ExperimentalFeatureWarning.

Returns:

Name Type Description
Conversion

The Turtle; str() of it is the text

to_api_json

to_api_json()

Write this model out in the OMG API's JSON element form.

It is the same experimental RDF mapping as Turtle, spelled as the element objects the SysML v2 API serves.

Returns:

Name Type Description
Conversion

The JSON; str() of it is the text

save

save(path, to_format=None, tolerate_syntax_errors=False)

Write this model to path, in the format its extension names.

Parameters:

Name Type Description Default
path str

File to write, created or truncated

required
to_format str

Format to write, overriding the extension

None
tolerate_syntax_errors bool

Write notation back out even when the parser could not read all of it

False

Returns:

Name Type Description
Conversion

What was written

Raises:

Type Description
ValueError

If no to_format was given and the extension names none

ConversionError

If the model could not be written in that format

edit

edit()

Start an edit of this model, to be applied in one call.

The editor collects operations naming elements by the ids this model reports, and Editor.apply has the service perform them on the source it parsed: the edited spans are replaced and every other byte, comments and layout included, comes back unchanged.

The service holds that source in its bounded model cache, so a model loaded long ago may have been evicted; load it again to edit it.

Returns:

Name Type Description
Editor

The editor, empty. Applying an empty one is an error.

Example

edit = model.edit() edit.set_value("Demo::sc::unitMass", "1050.0[SI::kg]") edit.apply().save("spacecraft.sysml") 'spacecraft.sysml'

query

query(payload=None, scope=None, select=None, where=None)

Run a SysML v2 API & Services Query over this model.

Takes the standard's Query JSON, so a payload written for the standard's API works verbatim, or the same thing as keywords. The query model has no graph traversal: "everything under this element" is a scope, not a constraint. See docs/reference/api.md.

Parameters:

Name Type Description Default
payload dict

The standard's Query object

None
scope list

Elements to consider, by qualified name; empty considers the whole loaded model

None
select list

Properties to report; empty reports every one

None
where dict

Constraint to filter by

None

Returns:

Type Description

list[QueryElement]: The elements selected, in declaration order

Raises:

Type Description
QueryError

If the query is not one the standard's model describes

MissingCapabilityError

If the service cannot query

InvalidRequestError

If a property or scope is unknown to the service

ModelNotFoundError

If the service no longer holds this model

Example

model.query({"@type": "Query", "where": { ... "@type": "PrimitiveConstraint", ... "operator": "=", "property": "@type", "value": ["PartUsage"]}}) [Demo::vehicle (PartUsage)]

run_document_query

run_document_query(query_id, bindings=None)

Run one of this model's named document queries.

The query is the model's own — a calc def specializing DocumentQueries::Query — not the standard's Query object query evaluates. See opensysml.document.

Parameters:

Name Type Description Default
query_id str

Qualified name of the document query

required
bindings Mapping

Parameter name to a value or list of values; an ElementRef binds a model element, an ObjectRef an object instantiate built, by id or by path

None

Returns:

Name Type Description
DocumentQueryResult

Projected columns and typed rows, in the

engine's deterministic order

Raises:

Type Description
MissingCapabilityError

If the service cannot run document queries

InvalidRequestError

If the query is not one, or a binding is wrong

SymbolNotFoundError

If this model does not declare the query, or an object binding names an object this model does not hold

ModelNotFoundError

If the service no longer holds this model

Example

from opensysml.document import ElementRef result = model.run_document_query( ... "Observatory::SubsystemTable", ... bindings={"root": ElementRef("Observatory::telescope")}) result.columns ('name', 'mass')

render_document

render_document(document_id, form='markdown')

Render one of this model's named documents to Markdown or HTML.

The document is a part def specializing DocumentQueries::Document, whose queries are bound in the model.

Parameters:

Name Type Description Default
document_id str

Qualified name of the document

required
form str

"markdown" (the default) or "html", the standalone page the CLI's -doc-form html writes

'markdown'

Returns:

Name Type Description
str

The rendered document in the form asked for

Raises:

Type Description
ValueError

If form is neither "markdown" nor "html"

MissingCapabilityError

If the service cannot render documents, or cannot render HTML when that form is asked for

InvalidRequestError

If the symbol named is not a document

SymbolNotFoundError

If this model does not declare the document

ModelNotFoundError

If the service no longer holds this model

Example

markdown = model.render_document("Observatory::MassReport") markdown.splitlines()[0] '# Telescope Mass Report' html = model.render_document("Observatory::MassReport", form="html") html.startswith("<!DOCTYPE html>") True

render_view

render_view(view_name, ports='minimal') -> RenderedView

Render one named view as typed diagram data.

Parameters:

Name Type Description Default
view_name str

Qualified view name or targeted pseudo-view

required
ports str

"minimal" (the default) or "full"

'minimal'

Returns:

Name Type Description
RenderedView RenderedView

Ordered nodes, edges, table data and optional layout

Raises:

Type Description
ValueError

If ports is neither "minimal" nor "full"

MissingCapabilityError

If the service cannot render views

InvalidRequestError

If the view is malformed or does not render

ViewNotFoundError

If the view or pseudo-view target is missing; also a SymbolNotFoundError and KeyError

ModelNotFoundError

If the service no longer holds this model

export_graphs

export_graphs(subject) -> Graphs

Export the lowered graph of an action or state machine.

The graph is the subject's and that of every behavior it performs, in the canonical graphs:1 JSON an external analysis engine is sent: nodes, edges, flows, parameters, guards, triggers and effects, with source spans.

Parameters:

Name Type Description Default
subject str

Qualified name of an action or state machine, definition or usage

required

Returns:

Name Type Description
Graphs Graphs

The JSON, its version and the subject as resolved

Raises:

Type Description
MissingCapabilityError

If the service cannot export graphs

SymbolNotFoundError

If the model declares no such element

InvalidRequestError

If the element is no action or state machine, or the name is shared by several elements

ModelNotFoundError

If the service no longer holds this model

find

find(name)

Find symbol by short name or fully-qualified name.

A symbol's own id is accepted as well as its short name, so the identifier a symbol reports can be round-tripped back into find. Several symbols may share a short name; the outermost wins, and among those the one declared first. A name declared in the model wins over a library symbol whose id it is, as Base is both a library package and a common name. Lookups are answered from the service's index, in one or two round trips whatever the size of the model.

Parameters:

Name Type Description Default
name str

Short name ("Vehicle") or FQN ("Demo::Vehicle")

required

Returns:

Type Description

Symbol or None: The matching symbol, or None if not found. Use

model[name] where a missing symbol is a failure, so it is

reported as one instead of as an AttributeError on None.

get

get(fqn)

Get symbol by fully-qualified name (e.g., "Demo::Vehicle").

Parameters:

Name Type Description Default
fqn str

Fully-qualified name to look up

required

Returns:

Type Description

Symbol or None: Matching symbol, or None if not found

eval

eval(expression, context_symbol_id=None, subject=None)

Evaluate a SysML expression against this model.

Parameters:

Name Type Description Default
expression str

SysML expression (e.g., "1 + 1")

required
context_symbol_id str

FQN of the symbol whose scope the expression's names resolve in

None
subject str

FQN of a part/usage to instantiate and evaluate against, as %eval does after %instantiate, so a feature reads that object's value rather than the declared default. Without a context the subject also names the scope.

None

Returns:

Type Description

The evaluated value, as a Python value

Raises:

Type Description
ExecutionError

If the expression could not be evaluated, or the subject is unknown or could not be instantiated

ModelNotFoundError

If the service no longer holds this model

UnsupportedValueError

If the result cannot be represented on the wire

Example

model.eval("1 + 1") 2 model.eval("mass", subject="Demo::car") 1600.0

instantiate

instantiate(symbol_id)

Build an object of one of this model's parts or usages.

Parameters:

Name Type Description Default
symbol_id str

FQN of the part/usage to instantiate

required

Returns:

Name Type Description
Instance

The object built, with its feature values and nested objects

Raises:

Type Description
ExecutionError

If the element could not be instantiated

ModelNotFoundError

If the service no longer holds this model

Example

model.instantiate("Demo::Vehicle").mass 1500.0

execute_action

execute_action(action_symbol_id, inputs=None, schedule=None, performer=None)

Execute one of this model's actions.

Parameters:

Name Type Description Default
action_symbol_id str

FQN of the action definition or usage

required
inputs dict

Input parameter name → Python value

None
schedule str

Scheduling policy the run resolves its choice points under — "declared", "reverse" (the default) or "seed:<n>"; "explore" belongs to explore_action

None
performer str

The object the action runs on: a part definition or usage to make an object of, or a path from one into its parts ("Mission::mission.vehicle"), made for the call and run inside its assembly

None

Returns:

Name Type Description
ActionOutputs

Output parameter name → value, a dict; an output the wire format cannot represent is reported as an UnsupportedValueError in its place, so one such output does not discard the rest. Its performer holds the performer's attributes under this. ('this.level'), empty without one

Raises:

Type Description
ValueError

If the schedule explores

ExecutionError

If the action could not be executed

ModelNotFoundError

If the service no longer holds this model

MissingCapabilityError

If a schedule is given and the service predates schedule, or a performer and it predates performer

InvalidRequestError

If the schedule names no policy

explore_action

explore_action(action_symbol_id, inputs=None, schedule='explore', performer=None)

Run one of this model's actions once per valid order of its choice points.

Parameters:

Name Type Description Default
action_symbol_id str

FQN of the action definition or usage

required
inputs dict

Input parameter name → Python value

None
schedule str

"explore" or "explore:runs=<n>,depth=<d>", bounding the runs made and the choice points one run resolves

'explore'
performer str

The object the action runs on, as for execute_action; every run makes it anew

None

Returns:

Name Type Description
Exploration

Every distinct outcome reached, each with the number of orders reaching it and the choices of one, and how the exploration ended

Raises:

Type Description
ValueError

If the schedule does not explore

ExecutionError

If the action could not be explored at all

ModelNotFoundError

If the service no longer holds this model

MissingCapabilityError

If the service predates schedule_explore, or performer when a performer is given

InvalidRequestError

If the schedule's options are malformed

execute_state

execute_state(state_machine_symbol_id, events=None, schedule=None, performer=None, trace=False)

Execute one of this model's state machines.

Parameters:

Name Type Description Default
state_machine_symbol_id str

FQN of the state machine definition or usage

required
events list

Event names to process, in order

None
schedule str

Scheduling policy the run resolves its choice points under, as for execute_action; "explore" belongs to explore_state

None
performer str

The object the machine runs on, as for execute_action; an object exhibiting the machine runs the one it exhibits, hearing its siblings over their connectors. Guards and actions read and write the object's feature values

None
trace bool

Whether to return the run's typed execution trace; requires the state_trace capability

False

Returns:

Name Type Description
dict

{'states_visited': [...], 'final_context': {...}, 'final_time': float, 'trace': [DocumentEvent, ...], 'trace_dropped': int}; final_context also holds the performer's attributes under this. ('this.speed'); a context value the wire format cannot represent is reported as an UnsupportedValueError in its place; final_time is the run's simulation clock when it ended, in seconds

Raises:

Type Description
ValueError

If the schedule explores

ExecutionError

If the state machine could not be executed; a traced failure carries its partial trace and trace_dropped

ModelNotFoundError

If the service no longer holds this model

MissingCapabilityError

If a schedule is given and the service predates schedule, a performer and it predates performer, or trace is requested and it predates state_trace

InvalidRequestError

If the schedule names no policy

explore_state

explore_state(state_machine_symbol_id, events=None, schedule='explore', performer=None)

Run one of this model's state machines once per valid order of its choice points.

Parameters:

Name Type Description Default
state_machine_symbol_id str

FQN of the state machine definition or usage

required
events list

Event names to process, in order

None
schedule str

"explore" or "explore:runs=<n>,depth=<d>"

'explore'
performer str

The object the machine runs on, as for execute_state; every run makes it anew

None

Returns:

Name Type Description
Exploration

Every distinct outcome reached — the state rested in, the states entered and the values held — and how the exploration ended

Raises:

Type Description
ValueError

If the schedule does not explore

ExecutionError

If the state machine could not be explored at all

ModelNotFoundError

If the service no longer holds this model

MissingCapabilityError

If the service predates schedule_explore, or performer when a performer is given

InvalidRequestError

If the schedule's options are malformed

verify_constraint

verify_constraint(symbol_id, subject=None, engine=None, question=None)

Ask whether one of this model's constraints holds.

Parameters:

Name Type Description Default
symbol_id str

FQN of the constraint definition or usage

required
subject str

FQN of a part/usage to instantiate and evaluate against, so the verdict is about concrete values

None
engine str

The engine to ask: "auto" (the default), "all", or one by name, as verify_constraint takes it

None
question str

The question to ask: "evaluate" (the default), "holds" whether the claim holds for every assignment the free features can take, or "satisfiable" whether any assignment satisfies it

None

Returns:

Name Type Description
Verdict

The answer; false is the model's answer, not an exception

Raises:

Type Description
WrongKindError

If symbol_id names an element that is not a constraint

ExecutionError

If the request could not be answered at all

verify_requirement

verify_requirement(symbol_id, subject=None, engine=None, question=None)

Ask whether one of this model's requirements is satisfied.

Parameters:

Name Type Description Default
symbol_id str

FQN of the requirement definition or usage

required
subject str

FQN of a part/usage to instantiate and evaluate against

None
engine str

The engine to ask, as for verify_constraint

None
question str

The question to ask, as for verify_constraint

None

Returns:

Name Type Description
Verdict

The answer

Raises:

Type Description
WrongKindError

If symbol_id names an element that is not a requirement

ExecutionError

If the request could not be answered at all

verify_satisfaction

verify_satisfaction(symbol_id=None, engine=None, question=None)

Ask whether this model's satisfaction assertions hold.

This is the scriptable form of "does this model satisfy its requirements?": every assert satisfy ... by ... the model states, each evaluated against an object of its subject.

Parameters:

Name Type Description Default
symbol_id str

FQN limiting evaluation to the assertions stated within that element, or to that element itself when it is a named satisfaction assertion

None
engine str

The engine to ask, as for verify_constraint

None
question str

The question to ask, as for verify_constraint

None

Returns:

Type Description

list[Verdict]: One verdict per assertion, in declaration order. An element stating none gives an empty list.

Raises:

Type Description
WrongKindError

If symbol_id names an element that can state no satisfaction assertion

ExecutionError

If the request could not be answered at all

satisfied

satisfied(symbol_id=None)

Whether every satisfaction assertion evaluated holds.

A model stating no assertion is trivially satisfied, so read this together with verify_satisfaction where that matters. An assertion that could not be evaluated is not a holding one.

Parameters:

Name Type Description Default
symbol_id str

FQN limiting evaluation, as in verify_satisfaction

None

Returns:

Name Type Description
bool

True when no assertion fails

validate_instance

validate_instance(symbol_id, engine=None)

Check every assertion about an object of one of this model's parts.

This is the scriptable form of sysml -validate=<object>: an object of the part is built, and each asserted constraint, requirement and satisfaction assertion in its tree is evaluated against the object carrying it, nested parts and every element of a collection included.

Parameters:

Name Type Description Default
symbol_id str

FQN of the part definition or usage an object of which is validated

required
engine str

The engine to ask, as for verify_constraint

None

Returns:

Name Type Description
Validation

One verdict per assertion and the object's own; truthy when every assertion holds and the whole tree was reached

Raises:

Type Description
ExecutionError

If the request could not be answered at all

calc

calc(symbol_id, arguments=None, engine=None)

Invoke one of this model's calculations.

Parameters:

Name Type Description Default
symbol_id str

FQN of the calc definition or usage

required
arguments list

Positional arguments, as Python values

None
engine str

The engine to ask, as for verify_constraint

None

Returns:

Name Type Description
CalcResult

The value returned, or the outputs a calc usage computed

Raises:

Type Description
WrongKindError

If symbol_id names an element that is not a calc

ExecutionError

If the calculation could not be evaluated

run_analysis

run_analysis(symbol_id, subject=None, arguments=None, named_arguments=None, schedule=None, engine=None)

Run one of this model's analysis cases.

Parameters:

Name Type Description Default
symbol_id str

FQN of the analysis case definition or usage

required
subject str

FQN of a part/usage to instantiate and run the case on; a usage binding its own subject needs none

None
arguments list

Positional arguments for the case's in parameters, as Python values

None
named_arguments dict

Arguments by parameter name

None
schedule str

Scheduling policy the actions the case performs resolve their choice points under, as for execute_action; "explore" belongs to explore_analysis

None
engine str

The engine to ask, as for verify_constraint; "explore" belongs to explore_analysis

None

Returns:

Name Type Description
AnalysisResult

The outputs the case computed and the verdict of its objective and assertions

Raises:

Type Description
ValueError

If the schedule or the engine explores

WrongKindError

If symbol_id names an element that is not an analysis case

ExecutionError

If the case could not run

InvalidRequestError

If the schedule names no policy, or the engine names none the service registers

explore_analysis

explore_analysis(symbol_id, subject=None, arguments=None, named_arguments=None, schedule='explore')

Run one of this model's analysis cases once per valid order of its actions' choice points.

Parameters:

Name Type Description Default
symbol_id str

FQN of the analysis case definition or usage

required
subject str

FQN of a part/usage to instantiate and run the case on

None
arguments list

Positional arguments, as Python values

None
named_arguments dict

Arguments by parameter name

None
schedule str

"explore" or "explore:runs=<n>,depth=<d>"

'explore'

Returns:

Name Type Description
Exploration

Every distinct outcome reached — the case's outputs and its objective and assertion verdicts — and how the exploration ended

Raises:

Type Description
ValueError

If the schedule does not explore

WrongKindError

If symbol_id names an element that is not an analysis case

ExecutionError

If the case could not be explored at all

MissingCapabilityError

If the service predates schedule_explore

InvalidRequestError

If the schedule's options are malformed

run_sweep

run_sweep(symbol_id, ranges, subject=None, arguments=None, named_arguments=None, samples=0, seed=0, engine=None)

Run one of this model's analysis cases or calcs once per swept row.

Parameters:

Name Type Description Default
symbol_id str

FQN of the analysis case or calc

required
ranges dict

Range per swept parameter, {"speed": (0, 10, 2)}

required
subject str

FQN of a part/usage to instantiate and run an analysis case on

None
arguments list

Positional arguments every row binds

None
named_arguments dict

Arguments by name every row binds

None
samples int

Rows to draw rather than step through

0
seed int

Seed the draws are taken from

0
engine str

The engine to ask, as for verify_constraint

None

Returns:

Name Type Description
SweepTable

One row per run, in the order the runs were made

Raises:

Type Description
WrongKindError

If symbol_id names neither an analysis case nor a calc

ExecutionError

If no run followed from the request

Model.execute_state(..., trace=True) returns typed DocumentEvent records in the result's trace list and the discarded-record count in trace_dropped. The option is capability-gated by state_trace and cannot be combined with an explore schedule; the same option and result fields are available on Connection.execute_state. A failed traced run raises the existing ExecutionError, with its partial records on trace and discarded count on trace_dropped.

opensysml.symbol

Symbols represent declarations and their resolved facts in a model.

opensysml.Symbol

Represents a symbol in the SysML model (definition or usage).

Wraps a SymbolInfo protobuf message and provides lazy navigation through the symbol tree via an optional RPC client.

Attributes:

Name Type Description
id str

Unique symbol identifier (fully-qualified name)

name str

Simple name of the symbol

kind str

SysML element kind (e.g., "partDef", "attributeUsage")

id property

id: str

Return symbol ID (fully-qualified name).

name property

name: str

Return simple name.

kind property

kind: str

Return SysML element kind.

metadata property

metadata: dict

Return copy of symbol metadata dictionary.

type_facts property

type_facts: Optional[TypeFacts]

Return the symbol's static type, or None when it carries no type.

multiplicity property

multiplicity: Optional[Multiplicity]

Return the declared multiplicity range, or None when undeclared.

specializations property

specializations: List[Specialization]

Return all generalization edges declared on this symbol.

withheld_library_attributes property

withheld_library_attributes: int

Return how many standard-library-inherited attributes were withheld.

The service reports a model's own and non-library-inherited attributes; this says how many of the metamodel frame's it left out, so their absence is stated rather than silent.

attribute_facts

attribute_facts() -> List[AttributeFacts]

Return every attribute this symbol has, own and inherited, with its resolved type, constant default value and unit. Attributes inherited from standard-library content are withheld and counted by withheld_library_attributes.

This is the attribute set the service resolved, so unlike attributes it needs no further RPC and reports each attribute's default value.

Raises:

Type Description
MissingCapabilityError

The service does not report symbol_attributes, so it answers with an empty set that cannot be told from an element having no attributes.

facts

facts() -> SymbolFacts

Return this symbol's static facts, detached from the protobuf message.

attributes carries what the service reported, which is nothing from one predating the attribute set; attribute_facts names such a service instead.

children

children() -> List[Symbol]

Return all child symbols.

Lazily fetches child symbols using the RPC client if available. Caches results after first call. Returns empty list if no client is set.

Returns:

Type Description
List[Symbol]

List of child Symbol objects

attributes

attributes() -> List[Symbol]

Return the attribute symbols this symbol has, own and inherited.

Ordered as the service reports the attribute set, so an attribute inherited from a supertype is included and a redefinition masks the declaration it redefines. An inherited attribute is fetched from the supertype that declares it, so it carries its own facts.

Returns:

Type Description
List[Symbol]

List of attribute Symbol objects

parts

parts() -> List[Symbol]

Return child symbols that are part definitions or usages.

Returns:

Type Description
List[Symbol]

List of part Symbol objects

get_attr

get_attr(name: str) -> Optional[Symbol]

Get attribute by name.

Parameters:

Name Type Description Default
name str

Attribute name to search for

required

Returns:

Type Description
Optional[Symbol]

Symbol if found, None otherwise

to_dataframe

to_dataframe()

Convert this symbol's members to a pandas DataFrame.

One row per child, plus one per attribute inherited from a supertype, with columns: name, kind, id, type, multiplicity, value, unit, inherited. value and unit are an attribute's default where the service resolved a constant one, and are None where it did not.

Returns:

Type Description

pandas.DataFrame with this symbol's members

Raises:

Type Description
ImportError

If pandas is not installed

MissingCapabilityError

The service does not report symbol_attributes, so no default could be reported

opensysml.diagnostic

Diagnostics report parsing, analysis and execution findings.

opensysml.Diagnostic

Represents a parse diagnostic (error or warning).

Attributes:

Name Type Description
severity str

Diagnostic severity (e.g., "error", "warning")

message str

Diagnostic message

code str

Stable identifier of what was found (a validation code, "syntax", "choice-point", "guard-unevaluable"); "" when none

file str

Source file name

start_line int

Starting line number (1-based)

start_column int

Starting column number (1-based)

end_line int

Ending line number (1-based)

end_column int

Ending column number (1-based)

span

Protobuf Span object

severity property

severity

Get diagnostic severity.

message property

message

Get diagnostic message.

code property

code

Get the diagnostic code, independent of the message wording.

span property

span

Get protobuf Span object.

file property

file

Get source file name.

start_line property

start_line

Get starting line number (1-based).

start_column property

start_column

Get starting column number (1-based).

end_line property

end_line

Get ending line number (1-based).

end_column property

end_column

Get ending column number (1-based).

opensysml.enumeration

An enum literal carries its declaration identity and any scalar value.

opensysml.EnumLiteral dataclass

One literal of an enumeration definition.

A literal is its own identity, so it arrives as the declaration it names rather than as a number or a string: two literals are the same exactly when their literal_id is. It is frozen so it can be a dict key or set member, as the same literal in a model is one value.

enumeration_id, name and value describe the literal rather than identify it, so they take no part in equality or hashing: a literal named by its id alone is the same value as the fully described one the service sends.

Attributes:

Name Type Description
literal_id str

FQN of the literal's declaration ("D::Color::red")

enumeration_id str

FQN of the enumeration declaring it ("D::Color")

name str

The literal as a reader writes it ("Color::red")

value object

The scalar the literal equals when its enumeration specializes a scalar type (3 for high = 3 in enum def Level :> Integer), else None

opensysml.instance

An instance exposes feature values decoded from the service response.

opensysml.Instance

Represents a runtime instance of a part/usage.

Feature values are exposed as Python values: numbers, strings, booleans, lists and nested Instance objects. The protobuf messages remain reachable through get_feature() and raw_features.

Attributes:

Name Type Description
id int

Unique instance identifier

type_symbol_id str

FQN of the def/usage this instantiates

features dict

Feature name → Python value

id property

id

Get instance ID.

type_symbol_id property

type_symbol_id

Get type symbol FQN.

features property

features

Get all feature values as {feature_name: Python value}.

A feature whose value failed to evaluate or was never materialized is reported as a FeatureValueError object instead of raising, so the whole instance stays inspectable; attribute or item access on it raises.

raw_features property

raw_features

Get all feature values as {feature_name: sysml_pb2.FeatureValue}.

get_feature

get_feature(feature_name)

Get the raw protobuf feature value for a feature.

Parameters:

Name Type Description Default
feature_name str

Name of feature

required

Returns:

Type Description

sysml_pb2.FeatureValue or None if not found

get

get(feature_name, default=None)

Get a feature's Python value, or default if the feature does not exist.

Raises:

Type Description
FeatureValueError

If the feature exists but failed to evaluate.

opensysml.typed

The generated-class base supplies a typed view over an Instance.

opensysml.TypedObject

Base class of generated typed views over an Instance.

sysml_id class-attribute

sysml_id: str = ''

FQN of the SysML definition this class was generated from.

instance property

instance: Instance

Return the underlying Tier 1 instance.

from_instance classmethod

from_instance(instance: Instance) -> TypedObjectT

Return a typed view over instance, rejecting one of another type.

Accepted:

  • an instance of exactly this class's definition;
  • an instance of a definition that specializes it and has a generated class of its own — legitimate polymorphism, recognized because generation emits SysML specialization as Python inheritance;
  • an instance whose type no generated class in this process describes. The service reports the type of an instantiated usage as the usage's own FQN (Demo::myCar, not Demo::SportsCar), which no generated class carries, so the client cannot relate it to a definition at all. Rejecting it would break instantiating a usage, which is the ordinary way to get an instance, so an unrecognized type is accepted — the per-feature decoding in this module still reports a wrong shape.

Rejected: an instance whose type is described by a generated class that is not this class or a subclass of it.

Use unchecked to bypass this deliberately.

Raises:

Type Description
InstanceTypeError

If the instance's type is known to be another one.

unchecked classmethod

unchecked(instance: Instance) -> TypedObjectT

Return a typed view over instance without checking its type.

For a caller who knows better than the reported type — reading the feature values of a partially materialized instance, for instance. Accessing a property the instance does not have still raises from the decoder.

opensysml.typefacts

Static type, multiplicity and specialization facts resolved for symbols.

opensysml.TypeFacts dataclass

The static type of a usage, or the classification of a definition.

declared class-attribute instance-attribute

declared: str = ''

Type name as written; empty when none is declared.

resolved_id class-attribute instance-attribute

resolved_id: str = ''

FQN of the resolved type; empty when unresolved or undeclared.

resolved_kind class-attribute instance-attribute

resolved_kind: str = ''

Symbol kind of the resolved type, e.g. partDef.

primitive class-attribute instance-attribute

primitive: str = ''

Library scalar the type reduces to, e.g. Real; empty when it is not one.

primitive_source class-attribute instance-attribute

primitive_source: str = ''

Origin of primitive: declared, value or empty.

quantity class-attribute instance-attribute

quantity: bool = False

Values carry a measurement unit.

unit class-attribute instance-attribute

unit: str = ''

Unit as written, when the default value names one.

from_pb classmethod

from_pb(pb_type_info) -> TypeFacts

Build from a TypeInfo protobuf message.

opensysml.Multiplicity dataclass

A declared multiplicity range. A bound the service could not evaluate is empty.

is_collection property

is_collection: Optional[bool]

Whether the range admits more than one value, or None when unknown.

is_optional property

is_optional: Optional[bool]

Whether the range admits no value, or None when unknown.

from_pb classmethod

from_pb(pb_multiplicity) -> Multiplicity

Build from a MultiplicityInfo protobuf message.

opensysml.Specialization dataclass

One generalization edge: specializes, subsets, redefines or typing.

from_pb classmethod

from_pb(pb_specialization) -> Specialization

Build from a Specialization protobuf message.

opensysml.SymbolFacts dataclass

Everything code generation needs about one symbol.

opensysml.AttributeFacts dataclass

One attribute an element has, own or inherited, as the service resolves it.

type class-attribute instance-attribute

type: str = ''

FQN of the resolved type, else the type as written, else the library scalar.

value class-attribute instance-attribute

value: object = None

Default value, when it is a model-level constant; None when there is none.

unit class-attribute instance-attribute

unit: str = ''

Unit the default value is written in; empty when it carries none.

from_pb classmethod

from_pb(pb_attribute) -> AttributeFacts

Build from an AttributeInfo protobuf message.

opensysml.capabilities

Capability names and the error raised when a service omits required support.

opensysml.ServerInfo dataclass

Self-description of the service a Connection talks to.

Attributes:

Name Type Description
version str

Build version the service reports, informational only. Empty when the service is too old to answer.

capabilities FrozenSet[str]

Capability names the service reports.

answered bool

Whether the service answered the handshake at all. False means it predates GetServerInfo.

origin str

Human-readable provenance of the service — the binary path this client started, or the address it connected to. Used to name the offending binary in an error message.

has

has(capability: str) -> bool

Whether the service reports capability.

describe

describe() -> str

One-line description of the service, for an error message.

opensysml.MissingCapabilityError

Bases: OpenSysMLError

Raised when the connected service cannot supply a required capability.

Attributes:

Name Type Description
capability str

Capability name that was required

info ServerInfo

What the service reported about itself

opensysml.values

Decoded value kinds carried by the service wire format.

opensysml.UNSET module-attribute

UNSET = UnsetType()

opensysml.UnsetType

A feature holding no value: a valueless feature of a value type.

Distinct from None, the model's null. Falsy, reads as <unset> as every other surface spells it, and is a singleton, so is UNSET tests it.

opensysml.Undetermined dataclass

A model-level result the model leaves open (an unbound feature, an unfixed count).

Distinct from UNSET and None; spelled <undetermined>, and bool() raises. count_lower/count_upper bound its count as MultiplicityInfo spells them.

from_pb classmethod

from_pb(pb_undetermined) -> Undetermined

Build from an Undetermined protobuf message.

opensysml.Array dataclass

A multidimensional array: its shape and its elements in row-major order.

attribute grid : Array { :>> dimensions = (2, 3); :>> elements = (1, 2, 3, 4, 5, 6); } is Array((2, 3), (1, 2, 3, 4, 5, 6)). An element is any value a feature can hold, an Array or a Quantity included; elements holds them flattened as the model states them, with the last dimension varying fastest, and nested unfolds them. A rank-0 array holds exactly one element. Two arrays are equal when their shapes agree and each element is the same_value as its counterpart.

Attributes:

Name Type Description
dimensions tuple[int, ...]

Extent of each dimension, all positive

elements tuple

The elements, row-major

Raises:

Type Description
ValueError

If a dimension is not positive, or the elements do not fill the dimensions exactly.

rank property

rank: int

Number of dimensions.

nested

nested() -> Any

The elements as nested lists, one level per dimension; a rank-0 array is its element.

from_pb classmethod

from_pb(pb_array, resolve_instance=None) -> Array

Build from an Array protobuf message.

Raises:

Type Description
UnsupportedValueError

If the message's shape and elements disagree, or an element is one the service reported as unsupported.

to_pb

to_pb(encode: Callable[[Any], Value]) -> sysml_pb2.Array

Encode as an Array message, each element through encode.

opensysml.Vector dataclass

A vector of numbers, each an Integer or a Real as the model computed it.

VectorOf((3.0, 4.0)) is Vector((3.0, 4.0)). A component that is a bool or not a number is refused, as the service refuses it.

Attributes:

Name Type Description
components tuple[int | float, ...]

The components, in order

from_pb classmethod

from_pb(pb_vector) -> Vector

Build from a Vector protobuf message.

Raises:

Type Description
UnsupportedValueError

If a component is not an Integer or a Real.

to_pb

to_pb() -> sysml_pb2.Vector

Encode as a Vector message, Integer and Real components kept apart.

opensysml.VectorQuantity dataclass

A vector whose components are quantities, each with its own unit.

VectorOf((3.0, 4.0)) [SI::m] is VectorQuantity((Quantity(3.0, m), Quantity(4.0, m))); the units usually agree but need not — a position in polar coordinates holds a metre and a radian. Each component carries the unit as written and its reduction, as a Quantity does.

Attributes:

Name Type Description
components tuple[Quantity, ...]

The components, at least one

unit property

unit: Optional[Unit]

The one unit every component shares, or None when they differ.

magnitudes

magnitudes() -> Vector

The magnitudes as a Vector, each in its component's unit.

from_pb classmethod

from_pb(pb_vector_quantity) -> VectorQuantity

Build from a VectorQuantity protobuf message.

Raises:

Type Description
UnsupportedValueError

If it has no components, or a component is a quantity the client cannot read.

to_pb

to_pb() -> sysml_pb2.VectorQuantity

Encode as a VectorQuantity message, one Quantity per component.

opensysml.MeasurementRef dataclass

A measurement unit held as a value by itself, with no magnitude.

SI::m, km, or m / s as an operation composed it: what a MeasurementUnit-typed attribute or a quantity's mRef evaluates to, and what ConvertQuantity takes as its target. It carries the unit as a Quantity does — text and reduction — plus the declaration it names.

Two references are equal when they are one reduction at one scale, however spelt: SI::'m/s' is m / s and km / m is m / mm. A named unit of dimension one reduces to nothing, so it is only its own declaration: rad is not sr.

Attributes:

Name Type Description
unit Unit

The unit as written and its reduction to base units

unit_id str

FQN of the one unit declaration the reference names (SI::kilometre); empty for a unit an operation composed, which names none

from_pb classmethod

from_pb(pb_ref) -> MeasurementRef

Build from a MeasurementRef protobuf message.

Raises:

Type Description
UnsupportedValueError

If the message names no unit at all, or names one without the reduction commensurability is decided over.

to_pb

to_pb() -> sysml_pb2.MeasurementRef

Encode as a MeasurementRef message, unit as written.

Raises:

Type Description
UnsupportedValueError

If the unit is named without its reduction — the service decides commensurability over the reduction and rejects a unit sent without one.

opensysml.Function dataclass

A calc held as a value: a calc definition, or a calc usage with an input no read could supply, as Sq in Fn(Sq, 3.0) or the f of in calc f {...}.

It is the declaration it is a value of, which is its identity: two functions are equal exactly when calc_id and self_id are. A function closing over the bindings of the behavior body it is declared in has no wire form; the service sends it as an unsupported null.

Attributes:

Name Type Description
calc_id str

FQN of the calc declaration (Analysis::Sq)

self_id int

ID of the object the calc's feature names resolve against, for a calc usage read off a part (holder.scale); 0 for a function closing over no object. An instance ID, valid only within the response that sent it: the service rejects a function argument whose self_id is not 0, since no later call holds that object.

from_pb classmethod

from_pb(pb_fn) -> Function

Build from a Function protobuf message.

Raises:

Type Description
UnsupportedValueError

If the message names no calc.

to_pb

to_pb() -> sysml_pb2.Function

Encode as a Function message.

Raises:

Type Description
UnsupportedValueError

If the function names no calc.

opensysml.Metaobject dataclass

An element of the model held as an instance of its reflective metaclass: what x meta KerML::Feature, or the last element of x.metadata, evaluates to.

It is the element it reflects on, which is its identity: two metaobjects are equal exactly when element_id is, whatever type each was cast to. Its features (declaredName, ownedFeature, ...) are read in the model, not carried.

Attributes:

Name Type Description
element_id str

FQN of the element reflected on (Vehicle::seatBelt)

metaclass_id str

FQN of the element's own reflective metaclass (SysML::Systems::PartUsage), not the type it was cast to. The service always sends it; one sent to the service may be left empty to have the model's used, but one naming a metaclass that is not the element's is rejected.

from_pb classmethod

from_pb(pb_meta) -> Metaobject

Build from a Metaobject protobuf message.

Raises:

Type Description
UnsupportedValueError

If the message names no element.

to_pb

to_pb() -> sysml_pb2.Metaobject

Encode as a Metaobject message.

Raises:

Type Description
UnsupportedValueError

If the metaobject names no element.

opensysml.SetValue dataclass

A unique, unordered collection: a Collections::Set's elements.

Distinct from a list, whose order is part of its value. The service sends the elements in its canonical order, so equal sets arrive alike, and elements keeps that order for reading; equality ignores it. A set to send may hold its elements in any order — a Python set or frozenset is accepted too — but one listing an element twice, by same_value, is refused rather than read as one element. Elements need not be hashable: a nested list is one.

Attributes:

Name Type Description
elements tuple

The elements, each once, in the order held

Raises:

Type Description
ValueError

If an element is listed twice.

from_pb classmethod

from_pb(pb_set, resolve_instance=None) -> SetValue

Build from a ValueSet protobuf message, elements in the order sent.

Raises:

Type Description
UnsupportedValueError

If the message lists a member twice.

to_pb

to_pb(encode: Callable[[Any], Value]) -> sysml_pb2.ValueSet

Encode as a ValueSet message, each element through encode.

opensysml.TensorQuantity dataclass

A tensor quantity of any rank: its shape and one quantity per component.

TensorCalculations::'['((1.0, ..., 8.0), cubeRef) over a (2, 2, 2) reference is TensorQuantity((2, 2, 2), (Quantity(1.0, Pa), ...)), the components flattened row-major as an Array's are. A tensor of rank one is not a VectorQuantity, here as in the model.

Attributes:

Name Type Description
dimensions tuple[int, ...]

Extent of each dimension, all positive

components tuple[Quantity, ...]

The components, row-major

Raises:

Type Description
ValueError

If a dimension is not positive, a component is not a Quantity, or the components do not fill the dimensions.

rank property

rank: int

Number of dimensions.

unit property

unit: Optional[Unit]

The one unit every component shares, or None when they differ.

from_pb classmethod

from_pb(pb_tensor) -> TensorQuantity

Build from a TensorQuantity protobuf message.

Raises:

Type Description
UnsupportedValueError

If the message's shape and components disagree, or a component is a quantity the client cannot read.

to_pb

to_pb() -> sysml_pb2.TensorQuantity

Encode as a TensorQuantity message, one Quantity per component.

opensysml.InstanceRef dataclass

A reference to an instance the client has no instance graph to resolve.

It holds the instance's id and is nothing else: not the Integer of that value, so it is never equal to one nor accepted where a number is, and sent back it is again an instance reference.

Attributes:

Name Type Description
id int

The instance's id

Raises:

Type Description
ValueError

If the id is not an integer.

opensysml.INFINITY module-attribute

INFINITY = _Infinity()

opensysml.conversion

Format conversion and migration results, including experimental-feature notices.

opensysml.Conversion dataclass

A model written out in one of the formats OpenSysML writes.

Attributes:

Name Type Description
content str

The converted model. str(conversion) is this text, so a conversion can be written or compared directly.

from_format str

Format the source was read as. Reported even when it was inferred, so a caller learns what the inference decided.

to_format str

Format content is written in.

diagnostics List[object]

Syntax errors the service tolerated under tolerate_syntax_errors. Empty otherwise: a conversion that failed raises instead.

experimental bool

True when the conversion went through the RDF mapping, which is experimental. A notation conversion is stable.

experimental_notice str

What is experimental about it, in the service's own wording. Empty when experimental is False.

write

write(path)

Write the converted model to path.

The bytes written are the ones the service returned: newline="" turns off the translation text mode would otherwise apply to every line ending.

Parameters:

Name Type Description Default
path str

File to write, created or truncated.

required

Returns:

Name Type Description
str

The path written, for chaining.

opensysml.format_of_path

format_of_path(path)

Infer the format to write path as, from its extension.

Parameters:

Name Type Description Default
path str

File name or path.

required

Returns:

Name Type Description
str

Format name, as convert takes it.

Raises:

Type Description
ValueError

If the extension names no format this client can write.

opensysml.ExperimentalFeatureWarning

Bases: UserWarning

Warns that a conversion went through an experimental mapping.

Raised as a warning rather than an error: the conversion did happen. Silence it with warnings.simplefilter on this class, which no stable feature warns with, so silencing it cannot hide anything else.

opensysml.is_experimental

is_experimental(from_format, to_format)

Report whether a conversion between these formats uses an experimental mapping.

Parameters:

Name Type Description Default
from_format str

Format read, as the service reports it.

required
to_format str

Format written, as the service reports it.

required

Returns:

Name Type Description
bool

True when either side is RDF or the API's JSON element form, or

the input is SysML v1 XMI, which is migrated. Notation to notation is

stable.

opensysml.Migration dataclass

A SysML v1 model migrated to one of the formats OpenSysML writes.

Attributes:

Name Type Description
content str

The migrated model. str(migration) is this text.

from_format str

The v1 form read, canonically xmi: uml and mdzip name the same reader.

to_format str

Format content is written in.

report MigrationReport

What became of every element. Never None: the summary and the counts come back with every migration.

results str

The JSON index of the result snapshots the v1 tool stored, as -migration-results writes it, when asked for; else "".

files Dict[str, bytes]

Image files the model's diagrams embed, by the relative path content refers to them with, when there are any.

experimental bool

Always True: the migration is experimental.

experimental_notice str

What is experimental about it, in the service's own wording.

write

write(path)

Write the migrated model to path, and its image files beside it.

The files are written at their relative paths under path's directory, where the migrated model refers to them, as sysml -migrate -o writes them.

Parameters:

Name Type Description Default
path str

File to write, created or truncated.

required

Returns:

Name Type Description
str

The path written, for chaining.

opensysml.MigrationEntry dataclass

One SysML v1 element's verdict in a migration.

Attributes:

Name Type Description
id str

The element's xmi:id.

kind str

Its v1 metaclass, with its applied stereotypes.

name str

Its qualified name in the v1 model.

target str

The v2 element it was written as, when it was written.

verdict str

mapped, approximated, unmapped or skipped.

note str

Why the verdict is what it is, in the migrator's words.

opensysml.MigrationReport dataclass

The account a migration gives of itself: what became of every element.

The summary and the four counts always come back. entries and text come back when migrate is asked for the report; text is what sysml -migrate -migration-report writes.

Attributes:

Name Type Description
source str

The v1 model migrated, as the service named it.

exporter str

The tool that exported it, as its XMI says.

summary str

The one-line account, migrated N element(s): … mapped, … approximated, … unmapped (… skipped …).

mapped int

Elements with a faithful v2 form.

approximated int

Elements written in a v2 form that is not quite theirs.

unmapped int

Elements with no v2 form, left out and reported.

skipped int

Elements the migration does not consider: profile, library and notation-only content, and elements nothing refers to.

entries List[MigrationEntry]

Every element's verdict, when the report was asked for.

text str

The report as -migration-report writes it, when asked for.

by_verdict

by_verdict(verdict)

The entries with verdict: mapped, approximated, unmapped or skipped.

opensysml.is_v1

is_v1(from_format)

Report whether from_format names a SysML v1 model: xmi, uml or mdzip, read as the service reads a format name, in any case and padding.

opensysml.edit

Typed operations for changing a model's original notation.

opensysml.Editor

Operations to perform on a loaded model, and the call that performs them.

Collected client-side and applied in one call, so the service edits and validates the model once. Every operation names its element by the id a read reports (Symbol.id), or by the Symbol itself.

An editor is applied once: it describes an edit of the model it was made from, and the edited model is a different model. Build another editor from the reloaded model to edit again.

Example

edit = model.edit() edit.set_value("Demo::sc::unitMass", "1050.0[SI::kg]") edit.apply().save("spacecraft.sysml") 'spacecraft.sysml'

operations property

operations

The operations collected so far, in the order they were added.

applied property

applied

Whether this editor has been applied.

set_value

set_value(target, value)

Set the value expression of one of the model's features.

Replaces an existing = <expr>, or adds one before the terminating semicolon when the feature has none.

Parameters:

Name Type Description Default
target str or Symbol

Feature to edit, by FQN/id or symbol

required
value str

The new value, as SysML notation for one expression, e.g. "1050.0[SI::kg]", '"flight-2"' or "unitMass * 2"

required

Returns:

Name Type Description
Editor

self, so operations can be chained

Raises:

Type Description
TypeError

If value is not a string: the notation is what is sent, and guessing notation for a Python object would guess its type

rename

rename(target, new_name)

Rename one of the model's declarations.

Rewrites the declaration's name token and every reference to it in the model's source, including qualified names, alias targets and imports. A rename that would make another name mean the renamed element, or make this one mean something else, is refused with InvalidEditError.

Parameters:

Name Type Description Default
target str or Symbol

Declaration to rename, by FQN/id or symbol

required
new_name str

The new name, as it should read in the file

required

Returns:

Name Type Description
Editor

self, so operations can be chained

Raises:

Type Description
TypeError

If new_name is not a string

add_member

add_member(owner, kind, name, type=None, multiplicity=None, value=None, specializes=None, abstract=False, redefines=None, default=False, direction=None, metadata=None, expression=None, doc=None)

Add one declaration, using strings for all SysML/KerML notation.

expression writes a body expression for kinds whose bodies admit one: a constraint condition or a calc, case, analysis, verification, or use-case result expression. doc is plain documentation text, written as the new declaration's first body member doc /* ... */; it reads back unchanged as Documentation.body, and may not contain */ or a carriage return.

add_objective

add_objective(owner, name=None, type=None)

Add an objective member, unnamed when name is omitted.

add_verify

add_verify(owner, requirement)

Add verify <requirement>; to a verification case or its objective.

add_metadata

add_metadata(owner, metadata_type, values=None, name=None, about=None, shorthand=False)

Add a metadata usage or @ shorthand with optional values.

add_metadata_prefix

add_metadata_prefix(target, metadata_type)

Add a metadata prefix to an existing declaration.

add_documentation

add_documentation(target, body, name=None, locale=None, replace=False)

Add doc /* body */ as the first body member of a declaration.

A declaration ended by ; is given a body. One that already owns documentation is refused unless replace is true, which rewrites the one it owns (and is refused if it owns several).

Parameters:

Name Type Description Default
target str or Symbol

Declaration to document, by FQN/id or symbol

required
body str

Plain documentation text, exactly as Documentation.body reads back (whitespace included); it may not contain */, which closes a comment, or a carriage return

required
name str

Optional documentation name, doc name /* ... */

None
locale str

Optional locale, doc locale "en" /* ... */

None
replace bool

Rewrite the target's documentation instead of refusing when it has one

False

Returns:

Name Type Description
Editor

self, so operations can be chained

add_comment

add_comment(owner, body, name=None, about=None, locale=None)

Add comment [name] [about a, b] [locale "..."] /* body */ to a body.

The comment goes where a new member of owner goes; a declaration ended by ; is given a body, and an empty owner is the document root.

Parameters:

Name Type Description Default
owner str or Symbol

Namespace receiving the comment, by FQN/id or symbol; "" for the top level

required
body str

Plain comment text, exactly as Comment.body reads back (whitespace included); it may not contain */, which closes a comment, or a carriage return

required
name str

Optional comment name, comment name /* ... */

None
about list[str or Symbol]

Optional annotated elements, each a qualified name (or symbol) resolved from owner

None
locale str

Optional locale, comment locale "en" /* ... */

None

Returns:

Name Type Description
Editor

self, so operations can be chained

add_note

add_note(target, text)

Write the line note // text on its own line above a declaration.

A note is lexical trivia, not a model element: no query, export or to_api_json() sees it, but the edited text keeps it, and later edits that move or delete target carry it along.

Parameters:

Name Type Description Default
target str or Symbol

Declaration the note precedes, by FQN/id or symbol

required
text str

One line of note text; it may not contain a line break

required

Returns:

Name Type Description
Editor

self, so operations can be chained

add_satisfy

add_satisfy(owner, requirement, by=None, asserted=False, negated=False)

Add a satisfy usage to a body that admits behavior usages.

add_requirement_constraint

add_requirement_constraint(owner, kind, expression, name=None)

Add a require or assume constraint to a requirement-like body.

add_transition

add_transition(owner, source, target, name=None, trigger=None, guard=None, effect=None)

Add a transition with optional trigger, guard and effect clauses.

add_entry_transition

add_entry_transition(owner, target)

Add an entry transition to target in a state body.

add_first

add_first(owner, ref, after=None)

Emit first <ref>; (SysML.xtext:1384 InitialNodeMember; formal/2026-03-02).

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
ref

The node the first sequences from, a feature reference such as start or the name of a member the body declares.

required
after

Optional name of the body member the first follows; by default it is appended at the end of the body.

None

Raises:

Type Description
TypeError

If ref is not notation text or after is not a member name.

add_then

add_then(owner, ref=None, action=None, type=None, after=None, kind='action', multiplicity=None)

Emit then [m] <ref>; or then [m] <kind> <name> : <type>; (SysML.xtext:878, 887, 1703 TargetSuccession; formal/2026-03-02).

The member is sequenced after the member before it. A then item can only follow a member that is a succession source.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
ref

The node the then sequences to — a feature reference such as done or the name of a member the body declares.

None
action

The name of the member the then declares, written with kind (default "action") and an optional type. Exactly one of ref and action is required.

None
type

Optional typing target of the declared member.

None
after

Optional name of the body member the then follows: the new member sequences from it, and a then that previously followed it now sequences from the new member.

None
kind

The usage kind the then declares: "action", "perform action", "state", "merge", "decide", "join" or "fork".

'action'
multiplicity

Optional bracketed source-end multiplicity [m].

None

Raises:

Type Description
TypeError

If a text argument is not a string.

ValueError

If both or neither of ref and action is given, or ref comes with declaration fields, or the multiplicity is not valid for the requested form.

add_accept

add_accept(owner, payload, type=None, via=None, *, then=True, multiplicity=None, after=None)

Emit then [m] accept <payload> [: <type>] [via <via>]; (SysML.xtext:1442 AcceptNode; formal/2026-03-02).

Without then this emits the same notation without that prefix.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
payload

Payload parameter or trigger notation.

required
type

Optional accepted payload type.

None
via

Optional port expression.

None
then

Whether to prefix the statement with then.

True
multiplicity

Optional source-end multiplicity, emitted with then.

None
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string or then is not a bool.

ValueError

If multiplicity is used without then.

add_send

add_send(owner, payload, to=None, via=None, *, then=True, multiplicity=None, after=None)

Emit then [m] send <payload> [via <via>] [to <to>]; (SysML.xtext:1499 SendNode; formal/2026-03-02).

Without then this emits the same notation without that prefix.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
payload

Payload expression.

required
to

Optional receiver expression.

None
via

Optional port expression.

None
then

Whether to prefix the statement with then.

True
multiplicity

Optional source-end multiplicity, emitted with then.

None
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string or then is not a bool.

ValueError

If multiplicity is used without then.

add_assign

add_assign(owner, target, value, *, then=True, multiplicity=None, after=None)

Emit then [m] assign <target> := <value>; (SysML.xtext:1535 AssignmentNode; formal/2026-03-02).

Without then this emits the same notation without that prefix.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
target

Feature reference to assign.

required
value

Assigned expression.

required
then

Whether to prefix the statement with then.

True
multiplicity

Optional source-end multiplicity, emitted with then.

None
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string or then is not a bool.

ValueError

If multiplicity is used without then.

add_if

add_if(owner, condition, body, else_body=None, *, then=True, multiplicity=None, after=None)

Emit then [m] if <condition> { <body> } [else { <else_body> }] (SysML.xtext:1596 IfNode; formal/2026-03-02).

Without then this emits the same notation without that prefix. An empty else body is equivalent to omitting else.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
condition

Boolean condition expression.

required
body

Then-branch Body.

required
else_body

Optional else-branch Body.

None
then

Whether to prefix the statement with then.

True
multiplicity

Optional source-end multiplicity, emitted with then.

None
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string, then is not a bool, or a branch is not a Body.

ValueError

If multiplicity is used without then.

add_while

add_while(owner, condition, body, until=None, *, then=True, multiplicity=None, after=None)

Emit then [m] while <condition> { <body> } [until <until>]; (SysML.xtext:1615 WhileLoopNode; formal/2026-03-02).

Without then this emits the same notation without that prefix.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
condition

Loop condition expression.

required
body

Loop-body Body.

required
until

Optional post-condition expression.

None
then

Whether to prefix the statement with then.

True
multiplicity

Optional source-end multiplicity, emitted with then.

None
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string, then is not a bool, or body is not a Body.

ValueError

If multiplicity is used without then.

add_loop

add_loop(owner, body, until=None, *, then=True, multiplicity=None, after=None)

Emit then [m] loop { <body> } [until <until>]; (SysML.xtext:1615 WhileLoopNode; formal/2026-03-02).

Without then this emits the same notation without that prefix.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
body

Loop-body Body.

required
until

Optional post-condition expression.

None
then

Whether to prefix the statement with then.

True
multiplicity

Optional source-end multiplicity, emitted with then.

None
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string, then is not a bool, or body is not a Body.

ValueError

If multiplicity is used without then.

add_for

add_for(owner, variable, collection, body, type=None, *, then=True, multiplicity=None, after=None)

Emit then [m] for <variable> [: <type>] in <collection> { <body> } (SysML.xtext:1624 ForLoopNode; formal/2026-03-02).

Without then this emits the same notation without that prefix.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
variable

Loop variable name.

required
collection

Collection expression.

required
body

Loop-body Body.

required
type

Optional loop-variable type.

None
then

Whether to prefix the statement with then.

True
multiplicity

Optional source-end multiplicity, emitted with then.

None
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string, then is not a bool, or body is not a Body.

ValueError

If multiplicity is used without then.

add_terminate

add_terminate(owner, occurrence=None, *, then=True, multiplicity=None, after=None)

Emit then [m] terminate [<occurrence>]; (SysML.xtext:1641 TerminateNode; formal/2026-03-02).

Without then this emits the same notation without that prefix.

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
occurrence

Optional occurrence to terminate.

None
then

Whether to prefix the statement with then.

True
multiplicity

Optional source-end multiplicity, emitted with then.

None
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string or then is not a bool.

ValueError

If multiplicity is used without then.

add_guarded_then

add_guarded_then(owner, guard, ref, *, after=None)

Emit if <guard> then <ref>; (SysML.xtext:1708 GuardedTargetSuccession; formal/2026-03-02).

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
guard

Guard expression.

required
ref

Target reference.

required
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string.

add_else

add_else(owner, ref, *, after=None)

Emit else <ref>; (SysML.xtext:1714 DefaultTargetSuccession; formal/2026-03-02).

Parameters:

Name Type Description Default
owner

The action body, by qualified name or Symbol.

required
ref

Target reference.

required
after

Optional body member to insert after.

None

Raises:

Type Description
TypeError

If a notation argument is not a string.

add_import

add_import(owner, target, visibility=None, recursive=False, all=False, filter=None)

Add an import declaration to a namespace body or the document root.

target is the imported qualified name, optionally $::-rooted: A::B for a membership import, A::* for a namespace import. visibility is private, public or protected; None writes private, the indicator the grammar requires and the one legal in every body including the document root. recursive writes ::**, all writes import all, and filter is one expression string or a list or tuple of them, each written [<expression>].

add_require_constraint

add_require_constraint(owner, expression, name=None)

Add a require constraint to a requirement-like body.

add_assume_constraint

add_assume_constraint(owner, expression, name=None)

Add an assume constraint to a requirement-like body.

add_connection

add_connection(owner, kind, from_, to, name=None, type=None)

Add a connection-like usage between two feature references.

add_allocation

add_allocation(owner, from_, to, **kwargs)

Add an allocation ... allocate from_ to to usage.

add_flow

add_flow(owner, from_, to, **kwargs)

Add a flow ... from from_ to to usage.

add_succession

add_succession(owner, from_, to, **kwargs)

Add a succession ... first from_ then to usage.

delete

delete(target, cascade=False)

Delete a declaration, optionally removing declarations that refer to it.

move

move(target, owner)

Move a declaration into another namespace of the same document.

The declaration is carried with its body and owned comments to where add_member would insert it, and references to it are respelled so they still reach it. A move that would leave a reference no spelling restores is refused with MoveReferencedError.

Parameters:

Name Type Description Default
target str or Symbol

Declaration to move, by FQN/id or symbol

required
owner str or Symbol

Namespace to receive it; "" is the document root

required

Returns:

Name Type Description
Editor

self, so operations can be chained

apply

apply()

Have the service perform these operations and return the edited model.

The service edits the source it parsed, re-parses and re-analyses the result, and refuses to return content the parser could not read back.

Returns:

Name Type Description
EditResult

The edited notation, and what each operation changed

Raises:

Type Description
NoEditsError

If no operation was added

EditError

If the service refused the edit; the subclass names why

MissingCapabilityError

If the service cannot apply edits

ModelNotFoundError

If the service no longer holds this model

RuntimeError

If this editor was already applied

add_package

add_package(owner, name, **kwargs)

Add a package declaration.

add_part_def

add_part_def(owner, name, **kwargs)

Add a part def declaration.

add_part

add_part(owner, name, **kwargs)

Add a part declaration.

add_attribute_def

add_attribute_def(owner, name, **kwargs)

Add an attribute def declaration.

add_attribute

add_attribute(owner, name, **kwargs)

Add an attribute declaration.

add_item_def

add_item_def(owner, name, **kwargs)

Add an item def declaration.

add_item

add_item(owner, name, **kwargs)

Add an item declaration.

add_port_def

add_port_def(owner, name, **kwargs)

Add a port def declaration.

add_port

add_port(owner, name, **kwargs)

Add a port declaration.

add_class

add_class(owner, name, **kwargs)

Add a class declaration.

add_struct

add_struct(owner, name, **kwargs)

Add a struct declaration.

add_datatype

add_datatype(owner, name, **kwargs)

Add a datatype declaration.

add_classifier

add_classifier(owner, name, **kwargs)

Add a classifier declaration.

add_feature

add_feature(owner, name, **kwargs)

Add a feature declaration.

add_assoc

add_assoc(owner, name, **kwargs)

Add an assoc declaration.

add_behavior

add_behavior(owner, name, **kwargs)

Add a behavior declaration.

add_function

add_function(owner, name, **kwargs)

Add a function declaration.

add_predicate

add_predicate(owner, name, **kwargs)

Add a predicate declaration.

add_interaction

add_interaction(owner, name, **kwargs)

Add an interaction declaration.

add_metaclass

add_metaclass(owner, name, **kwargs)

Add a metaclass declaration.

add_calc_def

add_calc_def(owner, name, inputs=None, return_type=None, return_expression=None, expression=None, **kwargs)

Add a calc def with input parameters and an optional result.

return_expression requires return_type and is bound to that result parameter; it does not write a return <expr>; statement. expression writes the calculation body's result expression.

add_calc

add_calc(owner, name, inputs=None, return_type=None, return_expression=None, expression=None, **kwargs)

Add a calc with input parameters and an optional result.

return_expression requires return_type and is bound to that result parameter; it does not write a return <expr>; statement. expression writes the calculation body's result expression.

add_parameter

add_parameter(owner, direction, name, type=None, kind=None, **kwargs)

Add a directional parameter usage.

By default the usage spells without a kind keyword — in x : T;, an implicit directed usage. An explicit kind is passed through as today: kind="ref" writes in ref x : T;, which this runtime reads as a performer-bound reference parameter.

add_return

add_return(owner, name='', **kwargs)

Add a return parameter member.

add_action_def

add_action_def(owner, name, inputs=None, outputs=None, **kwargs)

Add an action def with input and output parameters.

add_action

add_action(owner, name, inputs=None, outputs=None, **kwargs)

Add an action with input and output parameters.

add_perform_action

add_perform_action(owner, name, type=None, **kwargs)

Add a perform action name : Type usage (SysML v2 7.17.6).

add_perform

add_perform(owner, action, doc=None)

Add a perform <action>; usage naming an existing action usage; the member is named by the action it references.

add_exhibit_state

add_exhibit_state(owner, name, type=None)

Add an exhibit state usage.

add_exhibit

add_exhibit(owner, state)

Add an exhibit <state>; usage named by its referenced state.

add_state_action

add_state_action(owner, kind, name, type=None)

Add an entry, do or exit action to a state body.

add_state_def

add_state_def(owner, name, **kwargs)

Add a state def declaration.

add_state

add_state(owner, name, **kwargs)

Add a state declaration.

add_constraint_def

add_constraint_def(owner, name, expression=None, **kwargs)

Add a constraint def; expression= writes { … } while value= writes a feature value with = ….

add_constraint

add_constraint(owner, name, expression=None, **kwargs)

Add a constraint; expression= writes { … } while value= writes a feature value with = ….

add_assert_constraint

add_assert_constraint(owner, name=None, type=None, expression=None, negated=False)

Add an asserted constraint usage, optionally negated.

add_assert

add_assert(owner, ref, negated=False)

Add an anonymous assert usage; the assertion is not named by ref.

add_requirement_def

add_requirement_def(owner, name, **kwargs)

Add a requirement def declaration.

add_requirement

add_requirement(owner, name, **kwargs)

Add a requirement declaration.

opensysml.Body

Chainable action-body items for nested if and loop statements.

The first ordinary statement is written without then by default, and later ordinary statements use it. Empty then/loop bodies emit { }. An empty else branch performs nothing, so an empty else_body is equivalent to omitting else.

The statement forms follow SysML.xtext:1368 ActionNodeMember, 1607 ActionBodyParameter, 1442 AcceptNode, 1499 SendNode, 1535 AssignmentNode, 1596 IfNode, 1615 WhileLoopNode, 1624 ForLoopNode, 1641 TerminateNode and formal/2026-03-02.

Example

editor.add_while( ... "Demo::A", "count < 2", Body().add_assign("count", "count + 1") ... )

operations property

operations

The body items collected so far.

add_first

add_first(ref)

Emit first <ref>; (SysML.xtext:1384 InitialNodeMember; formal/2026-03-02).

Parameters:

Name Type Description Default
ref

The node the body starts at.

required

Raises:

Type Description
TypeError

If ref is not notation text.

add_then

add_then(ref=None, action=None, type=None, kind='action', multiplicity=None)

Emit then [m] <ref>; or then [m] <kind> <action> : <type>; (SysML.xtext:878, 887, 1703 TargetSuccession; formal/2026-03-02).

Parameters:

Name Type Description Default
ref

The target reference, mutually exclusive with action.

None
action

The member name, mutually exclusive with ref.

None
type

Optional type of the declared action member.

None
kind

Declared member kind, defaulting to "action".

'action'
multiplicity

Optional bracketed source-end multiplicity [m].

None

Raises:

Type Description
TypeError

If a notation argument is not a string.

ValueError

If the arguments do not describe exactly one form.

add_action

add_action(name=None, type=None, kind='action')

Emit <kind> <name> : <type>; (SysML.xtext:1368 ActionNodeMember; formal/2026-03-02).

Parameters:

Name Type Description Default
name

Optional declared action name.

None
type

Optional action type.

None
kind

Body item kind, defaulting to "action".

'action'

Raises:

Type Description
TypeError

If a notation argument is not a string.

add_accept

add_accept(payload, type=None, via=None, *, then=None, multiplicity=None)

Emit accept <payload> [: <type>] [via <via>]; or then [m] accept ...; (SysML.xtext:1442 AcceptNode; formal/2026-03-02).

Parameters:

Name Type Description Default
payload

Payload parameter or trigger notation.

required
type

Optional accepted payload type.

None
via

Optional port expression.

None
then

Whether to prefix the item with then; None chooses plain for the first item and then thereafter.

None
multiplicity

Optional source-end multiplicity, emitted with then.

None

Raises:

Type Description
TypeError

If a notation argument is not a string.

ValueError

If multiplicity is used without then.

add_send

add_send(payload, to=None, via=None, *, then=None, multiplicity=None)

Emit send <payload> [via <via>] [to <to>]; or then [m] send ...; (SysML.xtext:1499 SendNode; formal/2026-03-02).

Parameters:

Name Type Description Default
payload

Payload expression.

required
to

Optional receiver expression.

None
via

Optional port expression.

None
then

Whether to prefix the item with then; None chooses plain for the first item and then thereafter.

None
multiplicity

Optional source-end multiplicity, emitted with then.

None

Raises:

Type Description
TypeError

If a notation argument is not a string.

ValueError

If multiplicity is used without then.

add_assign

add_assign(target, value, *, then=None, multiplicity=None)

Emit assign <target> := <value>; or then [m] assign ...; (SysML.xtext:1535 AssignmentNode; formal/2026-03-02).

Parameters:

Name Type Description Default
target

Feature reference to assign.

required
value

Assigned expression.

required
then

Whether to prefix the item with then; None chooses plain for the first item and then thereafter.

None
multiplicity

Optional source-end multiplicity, emitted with then.

None

Raises:

Type Description
TypeError

If a notation argument is not a string.

ValueError

If multiplicity is used without then.

add_if

add_if(condition, body, else_body=None, *, then=None, multiplicity=None)

Emit if <condition> { <body> } [else { <else_body> }] or then [m] if ... (SysML.xtext:1596 IfNode; formal/2026-03-02).

Parameters:

Name Type Description Default
condition

Boolean condition expression.

required
body

Then-branch Body.

required
else_body

Optional else-branch Body; an empty body means no else branch.

None
then

Whether to prefix the item with then; None chooses plain for the first item and then thereafter.

None
multiplicity

Optional source-end multiplicity, emitted with then.

None

Raises:

Type Description
TypeError

If a notation argument is not a string or body is not a Body.

ValueError

If multiplicity is used without then.

add_while

add_while(condition, body, until=None, *, then=None, multiplicity=None)

Emit while <condition> { <body> } [until <until>]; or then [m] while ... (SysML.xtext:1615 WhileLoopNode; formal/2026-03-02).

Parameters:

Name Type Description Default
condition

Loop condition expression.

required
body

Loop-body Body.

required
until

Optional post-condition expression.

None
then

Whether to prefix the item with then; None chooses plain for the first item and then thereafter.

None
multiplicity

Optional source-end multiplicity, emitted with then.

None

Raises:

Type Description
TypeError

If a notation argument is not a string or body is not a Body.

ValueError

If multiplicity is used without then.

add_loop

add_loop(body, until=None, *, then=None, multiplicity=None)

Emit loop { <body> } [until <until>]; or then [m] loop ... (SysML.xtext:1615 WhileLoopNode; formal/2026-03-02).

Parameters:

Name Type Description Default
body

Loop-body Body.

required
until

Optional post-condition expression.

None
then

Whether to prefix the item with then; None chooses plain for the first item and then thereafter.

None
multiplicity

Optional source-end multiplicity, emitted with then.

None

Raises:

Type Description
TypeError

If a notation argument is not a string or body is not a Body.

ValueError

If multiplicity is used without then.

add_for

add_for(variable, collection, body, type=None, *, then=None, multiplicity=None)

Emit for <variable> [: <type>] in <collection> { <body> } or then [m] for ... (SysML.xtext:1624 ForLoopNode; formal/2026-03-02).

Parameters:

Name Type Description Default
variable

Loop variable name.

required
collection

Collection expression.

required
body

Loop-body Body.

required
type

Optional loop-variable type.

None
then

Whether to prefix the item with then; None chooses plain for the first item and then thereafter.

None
multiplicity

Optional source-end multiplicity, emitted with then.

None

Raises:

Type Description
TypeError

If a notation argument is not a string or body is not a Body.

ValueError

If multiplicity is used without then.

add_terminate

add_terminate(occurrence=None, *, then=None, multiplicity=None)

Emit terminate [<occurrence>]; or then [m] terminate ...; (SysML.xtext:1641 TerminateNode; formal/2026-03-02).

Parameters:

Name Type Description Default
occurrence

Optional occurrence to terminate.

None
then

Whether to prefix the item with then; None chooses plain for the first item and then thereafter.

None
multiplicity

Optional source-end multiplicity, emitted with then.

None

Raises:

Type Description
TypeError

If a notation argument is not a string.

ValueError

If multiplicity is used without then.

add_guarded_then

add_guarded_then(guard, ref)

Emit if <guard> then <ref>; (SysML.xtext:1708 GuardedTargetSuccession; formal/2026-03-02).

Parameters:

Name Type Description Default
guard

Guard expression.

required
ref

Target reference.

required

Raises:

Type Description
TypeError

If guard or ref is not notation text.

add_else

add_else(ref)

Emit else <ref>; (SysML.xtext:1714 DefaultTargetSuccession; formal/2026-03-02).

Parameters:

Name Type Description Default
ref

Target reference.

required

Raises:

Type Description
TypeError

If ref is not notation text.

opensysml.EditResult dataclass

Bases: Conversion

The edited notation, as a Conversion.

str(result) is the edited text and result.save(path) writes it, so an edit is written the way a conversion is. content is the notation of a model of one document, which is every model this client loads; a model of several documents, edited through the service directly by a request that accepts documents, answers with its rewritten documents in documents and an empty content. A request not accepting them is refused on such a model, as every request was before documents existed.

Attributes:

Name Type Description
applied List[AppliedEdit]

What each operation changed, grouped by document in the order documents lists them and in source order within a document.

documents List[EditedDocument]

The edited notation of every document the edits rewrote, the edited document first: one entry for a model of one document. Empty from a service without the edit_documents capability, which answers content alone.

save

save(path)

Write the edited model to path.

Parameters:

Name Type Description Default
path str

File to write, created or truncated

required

Returns:

Name Type Description
str

The path written, for chaining

opensysml.AppliedEdit dataclass

One byte range an operation replaced in the source it saw.

Attributes:

Name Type Description
operation_index int

Position of the operation in the editor, so an applied edit is matched back to what asked for it.

target str

Element edited, by the id it was named with.

offset int

Byte offset where the replacement starts.

length int

Number of bytes replaced. Zero for a value added to a feature that had none: nothing was replaced, text was inserted.

old_text str

The bytes that were there.

new_text str

What replaced them.

document str

The document the bytes belong to, named as the parse named it; the model's one document for a model loaded from a file.

opensysml.EditedDocument dataclass

The edited notation of one document of the model.

Attributes:

Name Type Description
name str

The document's name as the parse named it: the file path of a loaded file, or the name inline content was loaded under.

content str

The edited notation, byte-identical to the source outside the edited spans.

opensysml.errors

The public exception hierarchy for client, service, model and edit failures.

opensysml.Referrer

One declaration referring to the target of a refused rename, delete or move.

Attributes:

Name Type Description
name str

The referring declaration, as the notation names it

document str

The document declaring it, as the parse named it

opensysml.OpenSysMLError

Bases: Exception

Base class for all opensysml errors.

opensysml.AnalysisRunError

Bases: ExecutionError

Raised when an analysis case could not run to its end and left something to inspect.

An unbound subject, an input with no value, a failing step, or an alternative a trade study could not evaluate. What the run established is kept, so the evaluations that did succeed and the objectives the failure left undecided stay inspectable; a failure leaving nothing — no outputs, evaluations, verdicts or objects — is a plain ExecutionError, as is a request refused before the run. An ExecutionError itself, since that is what such a failure used to be.

Attributes:

Name Type Description
message str

Error description

result AnalysisResult

The outputs, verdicts and evaluations the run left; each verdict is undecided, the failure its reason

diagnostics list

List of Diagnostic objects (if available)

opensysml.ChecksumMismatchError

Bases: ConnectionError

Raised when a downloaded binary does not match the checksum published for it.

A ConnectionError, since the service cannot be started, but its own class so that a possibly tampered download is never handled as a transport failure and answered from whatever was cached before.

Attributes:

Name Type Description
unpinned bool

False for a real mismatch; see UnpinnedReleaseError, which is the only one it is True for

opensysml.ConnectionError

Bases: OpenSysMLError, ConnectionError

Raised when the client cannot connect to or start the sysml-grpc service.

Also a built-in ConnectionError, for the same reason ExecutionError is a built-in RuntimeError: the name in a traceback promises the built-in, and a script reaching a service over a socket writes except ConnectionError.

Attributes:

Name Type Description
message str

Error description

code StatusCode

Status the call failed with, when the failure came from a call rather than from starting the service

opensysml.ConversionError

Bases: OpenSysMLError

Raised when the service could not write a model in the requested format.

Attributes:

Name Type Description
message str

Error description reported by the service

diagnostics list

Diagnostic objects behind the failure, when the source was notation the parser could not read

opensysml.ExecutionError

Bases: OpenSysMLError, RuntimeError

Raised when a runtime operation (eval/instantiate/execute/verify) fails.

Also a built-in RuntimeError, so except RuntimeError catches it — which is what the traceback's opensysml.errors.RuntimeError used to promise and not deliver. That old name is a deprecated alias of this class.

Attributes:

Name Type Description
message str

Error description

diagnostics list

List of Diagnostic objects (if available)

trace tuple[DocumentEvent, ...]

Partial ExecuteState trace on failure

trace_dropped int

Oldest trace records discarded by the service

opensysml.FeatureValueError

Bases: OpenSysMLError

Raised when a feature value could not be evaluated or was never materialized.

Attributes:

Name Type Description
feature_name str

Name of the feature

message str

Error description reported by the service

opensysml.MigrationError

Bases: OpenSysMLError

Raised when the service could not migrate a SysML v1 model at all.

An element the migration has no v2 form for is not an error — it is left unmapped and reported in the MigrationReport; this is raised when the source is not a v1 model the migrator can read.

Attributes:

Name Type Description
message str

Error description reported by the service

opensysml.EditError

Bases: OpenSysMLError

Raised when an edit to a model was refused, and nothing was changed.

The subclasses name the refusals a caller acts on differently. An edit is never a silent no-op: every refusal raises one of these.

Attributes:

Name Type Description
message str

Why the edit was refused, in the service's wording

failure str

Refusal kind, as the wire enum names it, e.g. 'EDIT_FAILURE_UNKNOWN_TARGET'

diagnostics list

Diagnostic objects behind the refusal — the parse errors of an unreadable new value, or the errors the edited notation was found to have

referring_elements list[str]

For a refused rename, delete or move, where the references it would have broken are made, each suffixed with its document in parentheses when that is not the edited one

referrers list[Referrer]

The same referrers, each with the document declaring it as a field of its own

opensysml.NoEditsError

Bases: EditError, ValueError

Raised when an editor with no operations was applied.

Applying nothing is a mistake in the caller, not an empty write: the model is not re-parsed and no file is written.

opensysml.EditTargetError

Bases: EditError, LookupError

Raised when the element an edit names cannot carry that edit.

Covers a target the model does not declare, one declared outside this model's own source, an ambiguous one, a target with no value to set, and one with no declared name to rename.

opensysml.InvalidEditError

Bases: EditError, ValueError

Raised when the new value or name itself cannot be read.

A value that does not parse as one expression, or a name that does not lex as an identifier, is refused before the model is touched.

opensysml.RenameReferencedError

Bases: EditError

Raised when a rename would break references to the renamed element.

Renaming a declaration rewrites its name token only, so a referenced element cannot be renamed this way. referring_elements says where the references are made.

opensysml.OverlappingEditsError

Bases: EditError, ValueError

Raised when two operations would edit the same bytes of the source.

opensysml.EditResultError

Bases: EditError

Raised when the edited notation could not be read back.

The service re-parses and re-analyses what it edited and returns no content if the edit introduced an error, so an unreadable model is never written. diagnostics says what the edit broke.

opensysml.OwnerNotFoundError

Bases: EditError

Raised when an add-member owner is not declared in the model.

opensysml.OwnerNotNamespaceError

Bases: EditError

Raised when an add-member owner cannot contain members.

opensysml.IllegalMemberKindError

Bases: InvalidEditError

Raised when a declaration kind is invalid for the source language.

opensysml.MemberNameTakenError

Bases: EditError

Raised when an owner already declares the requested member name.

opensysml.DeleteReferencedError

Bases: EditError

Raised when a referenced declaration is deleted without cascade.

opensysml.OwnerInsideTargetError

Bases: EditError

Raised when a move's new owner is the moved declaration or inside it.

opensysml.MoveReferencedError

Bases: EditError

Raised when a move would leave a reference no spelling can restore.

opensysml.ReferencedElsewhereError

Bases: EditError

Raised when a rename, delete or move is referred to from a document the edit cannot rewrite, such as a library; referrers names each one.

opensysml.InstanceTypeError

Bases: OpenSysMLError

Raised when a generated typed view is asked to wrap an instance of another type.

Attributes:

Name Type Description
expected str

FQN of the definition the generated class views

actual str

FQN the instance reports as its type

opensysml.InvalidRequestError

Bases: ServiceError, ValueError

Raised when the service rejects a request as malformed or unsupported.

Also a ValueError: an argument the service cannot accept is a bad argument, whether this client or the service caught it.

opensysml.ManifestSignatureError

Bases: ChecksumMismatchError

Raised when the signature on a release's checksum manifest does not verify.

A bundle was published and read, and it does not attest that this release pipeline produced this manifest — another signer, an expired certificate, or a manifest changed after signing. That is evidence, not absence, so it is a mismatch: no cached binary answers for it.

opensysml.ModelError

Bases: OpenSysMLError

Raised when a model the service parsed has errors and the caller wanted none.

Raised by load(..., strict=True), and by Model.raise_for_errors.

Attributes:

Name Type Description
message str

Error description naming the source and error count

diagnostics list

The error-severity Diagnostic objects

model Model

The model itself, so it stays inspectable after the raise

opensysml.ModelFileNotFoundError

Bases: ServiceError, FileNotFoundError

Raised when the service could not read the source file a call named.

Also a built-in FileNotFoundError, because that is what the failure is: the path does not name a readable file for the service's own process.

opensysml.ModelNotFoundError

Bases: ServiceError

Raised when the service no longer holds the model a call named.

Its model cache is bounded, so a model loaded long ago and many models back may have been evicted. Load it again.

opensysml.ServiceError

Bases: OpenSysMLError

Raised when the service fails a call, translated from its gRPC status.

The subclasses below name the statuses a caller acts on differently; this class itself is raised for every other status, so no failure escapes the hierarchy as a bare grpc.RpcError. The original is always __cause__.

Attributes:

Name Type Description
message str

Description the service reported

code StatusCode

Status code it failed the call with

opensysml.ServiceTimeoutError

Bases: ServiceError, TimeoutError

Raised when a call exceeded its deadline or was cancelled.

opensysml.StaleServiceError

Bases: ConnectionError

Raised when the service already listening is not the one asked for.

A service this client did not start is reported rather than stopped, since the client cannot assume the process is its own.

Attributes:

Name Type Description
address str

Address the mismatched service is listening on

reason str

How it differs from the service that was asked for

remedy str

What to do about it

info ServerInfo

What it reported about itself, or None when it could not be asked

opensysml.SymbolNotFoundError

Bases: OpenSysMLError, KeyError

Raised when a symbol a lookup required is not in the model.

Also a KeyError, since model["Vehicle"] is a subscript and is expected to raise one.

Attributes:

Name Type Description
name str

Name that was looked up

suggestions list[str]

Names in the model close enough to be typos of it

opensysml.ViewNotFoundError

Bases: SymbolNotFoundError

Raised when a declared view or pseudo-view target is absent.

opensysml.TypeMismatchError

Bases: OpenSysMLError

Raised when a feature holds a value of another type than its generated view declares.

Attributes:

Name Type Description
feature_name str

Name of the feature

expected str

Type the generated class declares

value

The value actually decoded

opensysml.UnpinnedReleaseError

Bases: ChecksumMismatchError

Raised when this opensysml pins no digest for the release being downloaded.

Nothing contradicts anything here, so calling it a checksum mismatch named the wrong cause: the release is simply not one this opensysml vouches for. A ChecksumMismatchError still, so an except clause written before this class existed keeps catching it, and a working cached binary may still be used because no download is under suspicion.

opensysml.UnsignedReleaseError

Bases: UnpinnedReleaseError

Raised when a release publishes no signature this opensysml can check.

An old release published before the pipeline signed its checksum manifest, one whose bundle asset is missing or unreadable, or an install without the sigstore dependency: no signature was checked, so the release is one this opensysml cannot vouch for, exactly as an unpinned one is.

opensysml.SigstoreUnavailableError

Bases: UnsignedReleaseError

Raised when the sigstore package the manifest is verified with is absent.

Or a package it depends on; the message names which. The release may well be signed; this install cannot check. An UnsignedReleaseError, since nothing was verified either way, but its own class so the remedy can name the package to install rather than the release. A release of opensysml ships the digests of its own core release, so this only arises for another release, or for an opensysml older than the release it is asked for.

Attributes:

Name Type Description
install_command str

The pip install that provides the package

opensysml.UnsupportedOperationError

Bases: ServiceError

Raised when the connected service does not implement the call at all.

Capability-aware client operations surface a service-side capability refusal as MissingCapabilityError; this is the fallback for an unclassified method or an older service.

opensysml.UnsupportedValueError

Bases: OpenSysMLError

Raised when the service sends a value the wire format cannot represent.

opensysml.WrongKindError

Bases: ExecutionError

Raised when a call named an element of another kind than it asks about.

Verifying Wheel as a constraint is a wrong request, not an undecided verdict about the model, so it raises as naming no element at all does. An ExecutionError, since that is what such a failure used to be.

opensysml.verdict

Typed outcomes for verification, validation, calculation and analysis.

opensysml.Verdict

One verification's answer.

Truthy when the condition holds, so a verdict reads as the answer it is::

if not model.verify_requirement("Demo::Range"):
    print(verdict.explain())

Attributes:

Name Type Description
kind str

What was verified: 'constraint', 'requirement', 'satisfy', an analysis case's 'objective' or 'assertion', or a validated 'object' as a whole

element_id str

FQN of the element verified; empty for an anonymous satisfaction assertion

element str

The element as a reader names it — its FQN, or the assertion as written ("satisfy Range by cruise")

holds bool

Whether the condition holds

condition str

The condition that evaluated to false, as written, when the runtime names one

instance_id int

Instance the verdict is about, 0 when it is about declared values alone

instance_type_id str

FQN of that instance's type

error str

Set when evaluation failed rather than the model answering false; holds is then False but is no verdict

instances list[Instance]

The objects the call reported: the one this verdict is about (instance_id) and those reachable from it. A call answering several assertions reports one graph for them all, so filter on instance_id to single out this verdict's own object

diagnostics list[Diagnostic]

Diagnostics the service reported

requirement_id str

FQN of the requirement a 'satisfy' verdict asserts satisfied; empty for every other kind and for an anonymous requirement

instance_path str

Where the object this verdict is about sits in a validated one (engine.injector, wheels[2]); empty for the validated object itself and outside a validation

verifications list[VerificationVerdict]

What the bodies of the verification cases verifying this verdict's own requirement answered, beside this verdict rather than instead of it. Empty when the model states none, when the requirement is named by no FQN, or when the service predates verification_verdicts

question str

The question the verdict answers: 'evaluate' for an evaluation; reported by a service advertising verification_questions, empty from one predating it

status str

The answer's status: holds | violated | undecided | satisfiable | unsatisfiable, as the service spells it

witness list[WitnessAssignment]

The assignment witnessing the answer: the free features' values for a violated 'holds' question or a satisfiable 'satisfiable' question

standing Standing

The engine that answered, the strength of its evidence and the bounds it ran under; unreported when the service predates engines

engine property

engine

Name of the engine that answered; empty when unreported.

strength property

strength

Strength of the evidence the answer rests on; empty when unreported.

bounds property

bounds

The bounds the engine ran under, each marked when it stopped at it.

kind property

kind

What was verified.

element_id property

element_id

FQN of the element verified.

element property

element

The element as a reader names it.

holds property

holds

Whether the condition holds.

condition property

condition

The condition that evaluated to false, as written, when named.

instance_id property

instance_id

Instance the verdict is about, 0 for none.

instance_type_id property

instance_type_id

FQN of the type of the instance the verdict is about.

requirement_id property

requirement_id

FQN of the requirement a satisfaction verdict asserts satisfied.

instance_path property

instance_path

Path from the validated object to the one this verdict is about.

question property

question

The question the verdict answers; empty when unreported.

status property

status

The answer's status, as the service spells it; empty when unreported.

witness property

witness

The assignment witnessing the answer, when the status carries one.

error property

error

Why evaluation failed, when it failed rather than answering.

evaluated property

evaluated

Whether holds is an answer about the model at all.

raise_for_error

raise_for_error()

Raise ExecutionError if evaluation failed.

A verdict of false raises nothing: it is the model's answer. Call this where a failure to evaluate must not be read as a failing verdict.

Returns:

Name Type Description
Verdict

self, so a call can be chained

Raises:

Type Description
ExecutionError

If the condition could not be evaluated

explain

explain()

One line saying what the verdict is and why, then its standing when reported.

opensysml.CalcResult

What a calculation computed.

A calculation invoked with arguments returns one value, which is value. A calc usage evaluated from its own members computes its output features instead, which are outputs — a mapping of feature name to value, in declaration order (SysML 7.17).

Attributes:

Name Type Description
value

The value an invocation returned, or None when outputs carry the answer

outputs dict

Output features a calc usage computed

diagnostics list[Diagnostic]

Diagnostics the service reported

standing Standing

The engine that answered, the strength of its evidence and the bounds it ran under; unreported when the service predates engines

opensysml.AnalysisResult

What an analysis case computed and decided.

Running a case computes its out and return values, which are outputs in declaration order, then checks its objective and each assert constraint in its body against them, which are verdicts (SysML 7.22). A verdict of false is the case's answer, not an exception; an objective that could not be decided carries the reason in verdict.error.

Attributes:

Name Type Description
outputs dict

Output features the case computed, by name; a value the wire format cannot represent is an UnsupportedValueError in its place

verdicts list[Verdict]

The objective and assertion verdicts, in the order the case states them

instances list[Instance]

The subject the case ran on and the objects reachable from it, then every object an output or an evaluation names; empty when the run named no object

diagnostics list[Diagnostic]

Diagnostics the service reported

verifications list[VerificationVerdict]

For a verification case, what its body answered, followed by the verdict of each subcase it performed; empty for an analysis case

evaluations list[CaseEvaluation]

Each application the run made of one of the case's calcs as a value — a trade study's evaluation of each alternative, in subject order; empty for a case making none, or for a service without the case_evaluations capability

standing Standing

The engine that ran the case, the strength of its evidence and the bounds it ran under; unreported when the service predates engines

selected property

selected

The evaluations of the alternatives the case selected; one for a trade study.

satisfied property

satisfied

Whether every objective and assertion holds; a case stating none is satisfied.

opensysml.CaseEvaluation

One application an analysis case made of one of its own calcs as a value.

A trade study (TradeStudies::TradeStudy) evaluates its evaluationFunction once per alternative to find the best; each such evaluation is reported, in subject order, with the alternative it was of, what it computed, and whether that alternative was the one selected.

Attributes:

Name Type Description
function_id str

FQN of the calc applied

arguments list

What it was applied to, as Python values; an alternative is the Instance it is

result

What it computed, or None when error says why nothing was

error str

Why the evaluation computed nothing; empty when it did

selected bool

Whether the case returned this evaluation's argument: the alternative a trade study selected

tied bool

Whether this evaluation computed what the selected one did without being selected, selectOne having taken the first

evaluated property

evaluated

Whether the evaluation computed a result.

explain

explain()

One line saying what was evaluated, what it gave, and whether it was selected.

opensysml.SweepRow

One run of a sweep: what it bound, what it produced, and how long it took.

A run that failed is a row like any other, carrying error in place of outputs, so one failing run does not lose the rest of the table.

Attributes:

Name Type Description
inputs dict

The swept parameters as this run bound them, by name

outputs dict

What the run produced, by name; a calc's returned value is named "result", and an object is the Instance the table carries for it

verdicts list[Verdict]

The objective and assertion verdicts of an analysis case; empty for a calc

seconds float

Wall time of this run

error str

Why this run failed; empty when it did not

evaluations list[CaseEvaluation]

Each application this run made of one of the case's calcs as a value — a trade study's evaluation of each alternative, in subject order; a failed run keeps the ones it made. Empty for a calc, or for a service without the case_evaluations capability

selected property

selected

The evaluations of the alternatives this run selected; one for a trade study.

failed property

failed

Whether this run failed rather than producing outputs.

opensysml.SweepTable

Every run of one sweep, in the order the runs were made.

A swept table runs lexicographically over its parameters in the order their ranges were given; a sampled one runs in draw order, and echoes the seed it was drawn from so the table can be reproduced.

Attributes:

Name Type Description
rows list[SweepRow]

One row per run

parameters list[str]

The swept parameters, in the order their ranges were given

sampled bool

Whether the rows were drawn rather than stepped through

seed int

The seed the rows were drawn from; 0 for a swept table

instances list[Instance]

The subjects the runs were about and the objects reachable from them; empty when no run bound a subject

diagnostics list[Diagnostic]

Diagnostics the service reported

standing Standing

The engine that ran the table, the strength of its evidence and the bounds it ran under; unreported when the service predates engines

failures property

failures

The runs that failed.

opensysml.Validation

Every assertion about one object and the objects it holds, answered.

Validating an object evaluates each asserted constraint, each requirement and each satisfaction assertion whose subject lies in the object's tree against the object carrying it, as sysml -validate=<object> and the REPL's %validate do. Truthy only when every assertion holds and the whole tree was reached, so a verdict that could not be decided is not a holding one and a tree cut short by the traversal bound is not valid.

Attributes:

Name Type Description
verdicts list[Verdict]

One per assertion, root first then each held object in traversal order; instance_path says which object it is about, empty for the root

summary Verdict

The object's own verdict, of kind 'object': holds when every assertion does, carries error when one could not be decided or the tree was cut short

instances list[Instance]

The object validated and every object reachable from it

bounded bool

Whether traversal stopped at its bound before reaching every held object, so the verdicts are not the whole answer

diagnostics list[Diagnostic]

Diagnostics the service reported

verifications list[VerificationVerdict]

What the bodies of the verification cases of the requirements met answered

standing Standing

The engine that answered; unreported when the service predates engines

valid property

valid

Whether the object is shown valid: at least one assertion, every one holding, and every held object reached.

violated property

violated

The verdicts the model answered false, as opposed to undecided ones.

undecided property

undecided

The verdicts whose condition could not be evaluated.

raise_for_error

raise_for_error()

Raise ExecutionError if any assertion could not be decided.

A verdict of false raises nothing: it is the model's answer.

Returns:

Name Type Description
Validation

self, so a call can be chained

opensysml.VerificationVerdict

What the body of a verification case answered when it ran.

This is a separate answer from whether a requirement is satisfied: the specification leaves the evaluation of a verdict unspecified, so the service runs the case's body and the library's own PassIf calculation and reports the VerdictKind that produced. It is reported beside the satisfaction verdicts, never instead of them.

Truthy only for a pass, so a body that decided nothing does not read as one.

Attributes:

Name Type Description
case_id str

FQN of the verification case that ran

kind str

The VerdictKind the body produced: 'pass', 'fail', 'inconclusive' or 'error'

detail str

Why an inconclusive body decided nothing, or the error that stopped the run; empty for a pass and a fail

subcase bool

Whether this is the verdict of a case performed by another, which the library states no roll-up for

requirement_id str

FQN of the requirement this verdict was reported for; empty for a case run for itself, as by run_analysis

case_id property

case_id

FQN of the verification case that ran.

kind property

kind

The VerdictKind the body produced.

detail property

detail

Why the body decided nothing, or the error that stopped its run.

subcase property

subcase

Whether this verdict is of a case performed by another.

requirement_id property

requirement_id

FQN of the requirement this verdict was reported for, if any.

explain

explain()

One line saying what the body answered and why.

opensysml.exploration

Outcomes and search metadata returned by behavior exploration.

opensysml.Exploration

Every distinct outcome a behavior reached under explore, and how the exploration ended.

Iterating an exploration yields its outcomes, in the service's canonical order, so the same model explores to the same sequence every time.

Attributes:

Name Type Description
outcomes list[Outcome]

The distinct outcomes reached

complete bool

Whether every linearization within the budget was run

runs int

How many runs were made

budgets_hit list[str]

The budgets the exploration ran into — "runs", "depth" — empty when it is complete

runs_budget int

The most runs the exploration would make

depth_budget int

The most choice points one run would resolve

failed_linearizations int

Runs whose outcomes carry runtime errors

probabilities_lower_bound bool

Whether weighted model probabilities are lower bounds — the exploration is incomplete and a budget kept some orders unexplored

status property

status

How the exploration ended, as sysml -schedule explore prints it.

raise_for_incomplete

raise_for_incomplete()

Raise an ExecutionError unless every linearization was run.

opensysml.Outcome

One distinct outcome an exploration reached.

Two runs agreeing on their observables — an action's output values; the state a machine rests in, the states it entered and the values it holds; a case's outputs and verdicts — are one outcome, however differently they got there. A run that failed is an outcome of its own, carrying error.

Attributes:

Name Type Description
outputs dict

The values the behavior holds at the end, by name; a value the wire format cannot represent is an UnsupportedValueError in its place. Empty for a failed run

final_state str

The state a state machine rests in; empty for an action

states_visited list[str]

The states a state machine entered, in order

error str

Why the run failed; empty for a run that completed

linearizations int

How many of the explored orders reached this outcome

probability float | None

Exact probability from the model's weighted draws, or None when this exploration made no weighted choice or the probability differs by scheduler

probability_range tuple[float, float] | None

Minimum and maximum model-draw probability over schedulers, when weighted

witness list[str]

The choices one run reaching it made, in run order; empty when the behavior had no choice point

diagnostics list[Diagnostic]

What the witness run reported, its choice points among them

failed property

failed

Whether the runs reaching this outcome failed rather than completed.

raise_for_error

raise_for_error()

Raise the run's failure as an ExecutionError, if it failed.

opensysml.action_run

Action outputs decoded from a completed run.

opensysml.ActionOutputs

Bases: dict

An action run's output parameters by name, and its performer's attributes.

The mapping holds the output parameters alone, as it always has; an output the wire format cannot represent is an UnsupportedValueError in its place.

Attributes:

Name Type Description
performer dict

The attributes the object the action ran on holds when the run ends, keyed as an explored Outcome's outputs key them ("this.level"); empty without a performer

opensysml.engines

Registered analysis engines and the evidence standing of their answers.

opensysml.Bound dataclass

One limit an engine ran under.

Attributes:

Name Type Description
name str

What the limit was on: steps, runs, depth, elements

limit int

The limit itself

reached bool

Whether the engine stopped at it, which lowered its strength

opensysml.EngineInfo dataclass

One engine the service registers, as list_engines reports it.

Attributes:

Name Type Description
name str

The engine's name, the spelling engine= selects it by

authority str

The strongest evidence it may claim, one of STRENGTH_*

answers tuple

The question kinds it answers

bounds tuple

The bounds it runs under

process str

The external process it needs, empty for an in-process engine

process_found str

Where that process was found, empty when it was not

ready bool

Whether it can run here

unavailable str

Why it cannot, when it cannot

kind str

built-in, tool or engine (one registered from a manifest)

protocol str

How it is spoken to: - for a built-in engine; for a tool, object for the one-JSON-object exchange or argv+<stdin> when the entry has an invocation block, with a /<reply format> suffix such as argv+none/csv when the reply block reads another format (the format alone when the entry has no invocation); <transport>/<protocol> such as stdio/1 for an engine entry

source str

The manifest file an external engine was read from, empty for a built-in one

command str

The resolved command of an external engine, empty for a built-in one

version str

The version its manifest declares, empty for a built-in one

served bool

Whether this service runs it; an external engine is listed unserved until the service is started with -serve-external-engines

of classmethod

of(pb)

An engine as the wire describes it.

explain

explain()

One line naming the engine, its kind, its authority, its questions and its status.

opensysml.Standing dataclass

How far an answer can be trusted: who answered, how strongly, within what.

Attributes:

Name Type Description
engine str

Name of the engine that answered; empty when the service predates engines or no engine covered the question

strength str

One of the STRENGTH_* spellings; empty when the service predates engines

bounds tuple

The bounds the engine ran under, each marked when it stopped at it

reported property

reported

Whether the service reported a standing at all.

reached property

reached

The bounds the engine stopped at.

of classmethod

of(pb)

The standing a response or verdict message carries.

explain

explain()

One phrase: observed by run, bounded by explore (runs 64 reached).

opensysml.query

Results and errors from the standard query model.

opensysml.QueryElement dataclass

An element a query selected.

Attributes:

Name Type Description
id str

Qualified name of the element, which is what a scope names it by.

type str

The element's metamodel type, e.g. PartUsage.

properties Dict[str, str]

The selected properties it has. A property an element does not have is absent rather than empty.

get

get(property_name, default=None)

Value of a selected property, or default if the element has none.

as_dict

as_dict()

The element as the standard's JSON names it: @id, @type, properties.

opensysml.QueryError

Bases: OpenSysMLError

Raised when a query payload is not one the standard's query model describes.

opensysml.sources

Named file and inline source documents parsed together into one model.

opensysml.SourceDocument dataclass

One document of a model parsed from several.

Exactly one of path and content is set. Build one with file or inline rather than the constructor.

Attributes:

Name Type Description
path str

File the service reads. Its extension says which notation it is; it is also the name diagnostics report.

content str

Inline model source, parsed under name.

name str

What diagnostics call inline content and what the model indexes it under; two documents of one model may not share a name. A file is named by its path, so this is empty for one.

language str

Notation of inline content, "sysml" (the default when None) or "kerml". Needs the inline_language capability when set.

document_name property

document_name: str

The name diagnostics report this document under: the path or name.

file classmethod

file(path: Union[str, PathLike[str]]) -> SourceDocument

A file the service reads, named by its path.

Parameters:

Name Type Description Default
path str or PathLike

Path to the .sysml or .kerml file, on the machine the service runs on

required

inline classmethod

inline(name: str, content: str, language: Optional[str] = None) -> SourceDocument

Inline content, reported and indexed under name.

Parameters:

Name Type Description Default
name str

Name diagnostics report the content under, such as "lib.sysml"

required
content str

The model source

required
language str

"sysml" or "kerml"; SysML when omitted

None

to_pb

to_pb() -> sysml_pb2.SourceDocument

The SourceDocument message that sends this document.

opensysml.document

Typed query rows, document values, and document and view render results.

opensysml.DocumentEvent dataclass

A row an Events query answered: one record of a session's trace.

Answered only; binding one is refused.

Attributes:

Name Type Description
kind str

"accept", "send", "transition", "entry", "exit", "do", "choice", "guard" or "terminate"

time Quantity | int | float

The instant the record was written at, in the runtime clock's unit — a Quantity when the clock carries one, a plain number otherwise

object Optional[ObjectRef]

The object the record is about; None for a record of the run as a whole

machine str

The state machine the record is about, as DocumentState.machine names it

state str

The state entered, exited or run (entry, exit and do records)

from_state str

The transition's source state

to_state str

The transition's target state

target Optional[ObjectRef]

The object a send was delivered to

event str

The accepted or sent event's type name

payload tuple

The accept's payload, one name = value text per attribute

alternatives tuple

What a choice drew from, in order

taken str

The alternative the choice took

text str

The record as the trace prints it

opensysml.DocumentQueryError

Bases: OpenSysMLError, ValueError

Raised when a binding cannot be written before anything is sent.

opensysml.DocumentQueryResult dataclass

A document query's answer: projected columns and typed rows, both in the deterministic order the engine reports.

Attributes:

Name Type Description
columns tuple

Projected property names, in projection order

rows tuple

The selected rows, in the engine's order

opensysml.RenderCanvas dataclass

opensysml.RenderEdge dataclass

opensysml.RenderGeometry dataclass

opensysml.RenderNode dataclass

opensysml.RenderNote dataclass

opensysml.RenderPoint dataclass

opensysml.RenderPort dataclass

opensysml.RenderRow dataclass

opensysml.RenderSpan dataclass

A source location carried by rendered view data.

opensysml.RenderStyle dataclass

opensysml.RenderedView dataclass

Lossless diagram data returned by RenderView.

opensysml.Graphs dataclass

The lowered graph of an action or state machine, returned by ExportGraphs.

Attributes:

Name Type Description
content str

The canonical graphs:<version> JSON an external analysis engine is sent, ending in one newline

version int

The version of the form, its version field

subject str

The qualified name of the behavior as resolved

opensysml.DocumentRow dataclass

One selected element and its projected cells, one per column.

Attributes:

Name Type Description
element ElementRef

The selected element itself; for an object row, the usage the object is held under; for a row a Verdicts query answered, the assertion checked; for a state or event row, the usage of the object the row is about

cells tuple

One value sequence per column, in column order

verdict Optional[DocumentVerdict]

The DocumentVerdict a row a Verdicts query answered carries; None for any other row

object Optional[ObjectRef]

The ObjectRef a row over held objects is about — one an Objects query enumerated, a bound object's part, or the object a state or event row is about; None for any other row

state Optional[DocumentState]

The DocumentState a row a States query answered carries; None for any other row

event Optional[DocumentEvent]

The DocumentEvent a row an Events query answered carries; None for any other row

opensysml.DocumentState dataclass

A row a States query answered: one active leaf state of one object.

Answered only; binding one is refused.

Attributes:

Name Type Description
object ObjectRef

The object whose state machine the row reads

machine str

The exhibited state usage ("lp"), or the state def's name

name str

The active leaf state's own name ("dim")

path str

The leaf's path from the machine's top level ("on.dim")

state Optional[ElementRef]

The state usage's declaration

region str

The orthogonal region declaring the leaf ("light"); empty when the leaf is not in one

enclosing tuple

The active composite states around the leaf, outermost first

opensysml.DocumentVerdict dataclass

A row a Verdicts query answered: an assertion checked on one object.

Answered only; binding one is refused.

Attributes:

Name Type Description
assertion ElementRef

The constraint, requirement, satisfy usage or verification case checked; its id is empty when the assertion is anonymous

kind str

"constraint", "requirement", "satisfaction" or "verification"

text str

The assertion as written ("assert constraint massKnown")

path str

The object checked, named from the element the query was bound to ("Garage::car.wheels[2]")

status str

"holds", "violated" or "undecided"

condition str

The condition that evaluated to false, as written; empty otherwise

reason str

Why the assertion is violated or undecided; empty when it holds

verification tuple

Verdict kinds ("pass", "fail", ...) of the verification cases verifying the requirement the row is about; a verification row's own kind

opensysml.ElementRef dataclass

A model element, named by qualified name.

Attributes:

Name Type Description
id str

Qualified name of the element

type str

Metamodel type name ("PartUsage", ...); empty when bound by a caller, reported when answered by the service

opensysml.ObjectRef dataclass

An object the service holds for the model, created by instantiate.

Bound, it names the object by path when set and by id otherwise; one setting both must name one object by both. Answered, it carries all three fields.

Attributes:

Name Type Description
id int

The object's id, as instantiate answered it

path str

The object by the label a session reaches it under: the qualified name it was instantiated as ("Garage::car"), its id ("#2"), or a path through feature values of either ("Garage::car.wheels[2]", "#2.wheels[2]"; indexes count from 1)

element Optional[ElementRef]

The usage the object is held under, its definition or usage; reported when answered, ignored when bound