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.CAPABILITY_CONSTRAINT_BODY_AUTHORING
module-attribute
¶
opensysml.CAPABILITY_STATE_ACTION_AUTHORING
module-attribute
¶
opensysml.CAPABILITY_RATIONAL_VALUES
module-attribute
¶
opensysml.CAPABILITY_CONVERT_DOCUMENTS
module-attribute
¶
opensysml.CAPABILITY_CONVERT_COMPACT
module-attribute
¶
opensysml.CAPABILITY_PARSE_SOURCES_AFFECTED
module-attribute
¶
opensysml.load ¶
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 |
'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 ¶
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 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 |
'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 |
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 ¶
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
|
'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 |
''
|
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 |
'localhost'
|
port
|
int
|
Service port (default: 50051) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Conversion |
The converted model; |
Warns:
| Type | Description |
|---|---|
ExperimentalFeatureWarning
|
If either format is RDF, whose mapping is
experimental (see |
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 |
False
|
host
|
str
|
Service hostname, or a |
'localhost'
|
port
|
int
|
Service port (default: 50051) |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Migration |
The migrated model and its report; |
Warns:
| Type | Description |
|---|---|
ExperimentalFeatureWarning
|
Always; the migration is experimental (see
|
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 |
'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 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 |
'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)
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 |
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. |
Raises:
| Type | Description |
|---|---|
StaleServiceError
|
If a release was asked for and this first answer shows the service is another one |
load ¶
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
|
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 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 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
( |
required |
strict
|
bool
|
Refuse a model the service reported errors for,
instead of returning one whose lookups fail later. The
|
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 |
||
|
names in |
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 |
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 |
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 |
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 |
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
|
False
|
results
|
bool
|
Ask for the JSON index of the result snapshots the
v1 tool stored, as |
False
|
layout_path
|
str
|
Path to an MTIP export whose diagram
layouts the migrated views are laid out from, as |
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 |
''
|
strict
|
bool
|
Write only standard notation, leaving an element
whose only v2 form is an OpenSysML extension unmapped, as
|
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 |
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 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]
|
|
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 |
MissingCapabilityError
|
If the service cannot apply edits |
ModelNotFoundError
|
If the model is no longer cached |
query ¶
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 |
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 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 |
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 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'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
The rendered document in the form asked for |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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 a named view with minimal or full ports.
export_graphs ¶
Export the lowered graph of an action or state machine as graphs:1 JSON.
get_symbol ¶
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 ¶
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 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 |
execute_action ¶
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 — |
None
|
performer
|
str
|
The object the action runs on, as
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ActionOutputs |
Output parameter name → value, a |
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 |
InvalidRequestError
|
If the schedule names no policy |
explore_action ¶
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'
|
performer
|
str
|
The object the action runs on, as for
|
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 |
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 |
None
|
performer
|
str
|
The object the machine runs on, as for
|
None
|
trace
|
bool
|
Whether to return the run's typed execution trace;
requires the |
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; |
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 |
InvalidRequestError
|
If the schedule names no policy |
explore_state ¶
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'
|
performer
|
str
|
The object the machine runs on, as for
|
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 |
InvalidRequestError
|
If the schedule's options are malformed |
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 |
verify_constraint ¶
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 |
None
|
question
|
str
|
The question to ask: |
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
|
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 |
InvalidRequestError
|
If the engine names none the service registers |
ModelNotFoundError
|
If the service no longer holds the model |
verify_requirement ¶
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
|
None
|
question
|
str
|
The question to ask, as for
|
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 |
InvalidRequestError
|
If the engine names none the service registers |
ModelNotFoundError
|
If the service no longer holds the model |
verify_satisfaction ¶
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
|
None
|
question
|
str
|
The question to ask, as for
|
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
|
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 |
InvalidRequestError
|
If the engine names none the service registers |
ModelNotFoundError
|
If the service no longer holds the model |
validate_instance ¶
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
|
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 |
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 |
InvalidRequestError
|
If the engine names none the service registers |
ModelNotFoundError
|
If the service no longer holds the model |
calc ¶
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
|
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 |
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
|
None
|
engine
|
str
|
The engine to ask, as for
|
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 |
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 |
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'
|
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
|
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
|
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
|
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 |
InvalidRequestError
|
If the engine names none the service registers |
ModelNotFoundError
|
If the service no longer holds the model |
opensysml.split_target ¶
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 |
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) |
root
property
¶
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
¶
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
¶
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.
errors
property
¶
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
¶
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
¶
Path this model was loaded from, or None if it was loaded inline.
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
|
convert ¶
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; |
Warns:
| Type | Description |
|---|---|
ExperimentalFeatureWarning
|
If the format is RDF, whose mapping is
experimental — see |
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 ¶
Write this model out as SysML textual notation.
Returns:
| Name | Type | Description |
|---|---|---|
Conversion |
The notation; |
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; |
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; |
save ¶
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 ¶
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 ¶
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 |
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 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 |
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 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'
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
The rendered document in the form asked for |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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 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'
|
Returns:
| Name | Type | Description |
|---|---|---|
RenderedView |
RenderedView
|
Ordered nodes, edges, table data and optional layout |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
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 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 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 |
|
|
|
|
|
reported as one instead of as an AttributeError on None. |
get ¶
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 ¶
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 |
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 ¶
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 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 — |
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 ( |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
ActionOutputs |
Output parameter name → value, a |
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 |
InvalidRequestError
|
If the schedule names no policy |
explore_action ¶
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'
|
performer
|
str
|
The object the action runs on, as for
|
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 |
InvalidRequestError
|
If the schedule's options are malformed |
execute_state ¶
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 |
None
|
performer
|
str
|
The object the machine runs on, as for
|
None
|
trace
|
bool
|
Whether to return the run's typed execution trace;
requires the |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
{'states_visited': [...], 'final_context': {...}, 'final_time': float,
'trace': [DocumentEvent, ...], 'trace_dropped': int};
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the schedule explores |
ExecutionError
|
If the state machine could not be executed; a
traced failure carries its partial |
ModelNotFoundError
|
If the service no longer holds this model |
MissingCapabilityError
|
If a schedule is given and the service
predates |
InvalidRequestError
|
If the schedule names no policy |
explore_state ¶
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'
|
performer
|
str
|
The object the machine runs on, as for
|
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 |
InvalidRequestError
|
If the schedule's options are malformed |
verify_constraint ¶
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: |
None
|
question
|
str
|
The question to ask: |
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 ¶
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
|
None
|
question
|
str
|
The question to ask, as for
|
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 ¶
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
|
None
|
question
|
str
|
The question to ask, as for
|
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 ¶
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
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
True when no assertion fails |
validate_instance ¶
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
|
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 ¶
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
|
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
|
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
|
None
|
engine
|
str
|
The engine to ask, as for
|
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 ¶
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'
|
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 |
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, |
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
|
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") |
type_facts
property
¶
Return the symbol's static type, or None when it carries no type.
multiplicity
property
¶
Return the declared multiplicity range, or None when undeclared.
specializations
property
¶
Return all generalization edges declared on this symbol.
withheld_library_attributes
property
¶
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 ¶
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
|
facts ¶
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 ¶
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 ¶
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 ¶
Return child symbols that are part definitions or usages.
Returns:
| Type | Description |
|---|---|
List[Symbol]
|
List of part Symbol objects |
get_attr ¶
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 ¶
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
|
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 |
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 ( |
enumeration_id |
str
|
FQN of the enumeration declaring it ( |
name |
str
|
The literal as a reader writes it ( |
value |
object
|
The scalar the literal equals when its enumeration specializes a
scalar type ( |
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 |
features
property
¶
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
¶
Get all feature values as {feature_name: sysml_pb2.FeatureValue}.
get_feature ¶
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 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
¶
FQN of the SysML definition this class was generated from.
from_instance
classmethod
¶
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, notDemo::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
¶
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
¶
Type name as written; empty when none is declared.
resolved_id
class-attribute
instance-attribute
¶
FQN of the resolved type; empty when unresolved or undeclared.
resolved_kind
class-attribute
instance-attribute
¶
Symbol kind of the resolved type, e.g. partDef.
primitive
class-attribute
instance-attribute
¶
Library scalar the type reduces to, e.g. Real; empty when it is not one.
primitive_source
class-attribute
instance-attribute
¶
Origin of primitive: declared, value or empty.
quantity
class-attribute
instance-attribute
¶
Values carry a measurement unit.
unit
class-attribute
instance-attribute
¶
Unit as written, when the default value names one.
opensysml.Multiplicity
dataclass
¶
A declared multiplicity range. A bound the service could not evaluate is empty.
opensysml.Specialization
dataclass
¶
One generalization edge: specializes, subsets, redefines or typing.
from_pb
classmethod
¶
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
¶
FQN of the resolved type, else the type as written, else the library scalar.
value
class-attribute
instance-attribute
¶
Default value, when it is a model-level constant; None when there is none.
unit
class-attribute
instance-attribute
¶
Unit the default value is written in; empty when it carries none.
from_pb
classmethod
¶
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. |
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. |
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.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
¶
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. |
nested ¶
The elements as nested lists, one level per dimension; a rank-0 array is its element.
from_pb
classmethod
¶
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 ¶
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
¶
Build from a Vector protobuf message.
Raises:
| Type | Description |
|---|---|
UnsupportedValueError
|
If a component is not an Integer or a Real. |
to_pb ¶
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 |
from_pb
classmethod
¶
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 ¶
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
( |
from_pb
classmethod
¶
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 ¶
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 ( |
self_id |
int
|
ID of the object the calc's feature names resolve
against, for a calc usage read off a part ( |
from_pb
classmethod
¶
Build from a Function protobuf message.
Raises:
| Type | Description |
|---|---|
UnsupportedValueError
|
If the message names no calc. |
to_pb ¶
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 ( |
metaclass_id |
str
|
FQN of the element's own reflective metaclass
( |
from_pb
classmethod
¶
Build from a Metaobject protobuf message.
Raises:
| Type | Description |
|---|---|
UnsupportedValueError
|
If the message names no element. |
to_pb ¶
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
¶
Build from a ValueSet protobuf message, elements in the order sent.
Raises:
| Type | Description |
|---|---|
UnsupportedValueError
|
If the message lists a member twice. |
to_pb ¶
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
|
from_pb
classmethod
¶
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 ¶
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.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. |
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 |
diagnostics |
List[object]
|
Syntax errors the service tolerated under
|
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 |
write ¶
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 ¶
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 |
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 ¶
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. |
from_format |
str
|
The v1 form read, canonically |
to_format |
str
|
Format |
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
|
files |
Dict[str, bytes]
|
Image files the model's diagrams embed, by the relative path
|
experimental |
bool
|
Always True: the migration is experimental. |
experimental_notice |
str
|
What is experimental about it, in the service's own wording. |
write ¶
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 |
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
|
|
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, |
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 |
by_verdict ¶
The entries with verdict: mapped, approximated, unmapped or skipped.
opensysml.is_v1 ¶
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'
set_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. |
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 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 an objective member, unnamed when name is omitted.
add_verify ¶
Add verify <requirement>; to a verification case or its objective.
add_metadata ¶
Add a metadata usage or @ shorthand with optional values.
add_metadata_prefix ¶
Add a metadata prefix to an existing declaration.
add_documentation ¶
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
|
required |
name
|
str
|
Optional documentation name, |
None
|
locale
|
str
|
Optional locale, |
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 [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; |
required |
body
|
str
|
Plain comment text, exactly as |
required |
name
|
str
|
Optional comment name, |
None
|
about
|
list[str or Symbol]
|
Optional annotated elements, each a
qualified name (or symbol) resolved from |
None
|
locale
|
str
|
Optional locale, |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Editor |
self, so operations can be chained |
add_note ¶
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 a satisfy usage to a body that admits behavior usages.
add_requirement_constraint ¶
Add a require or assume constraint to a requirement-like body.
add_transition ¶
Add a transition with optional trigger, guard and effect clauses.
add_entry_transition ¶
Add an entry transition to target in a state body.
add_first ¶
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 |
required | |
after
|
Optional name of the body member the |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
add_then ¶
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 |
None
|
|
action
|
The name of the member the |
None
|
|
type
|
Optional typing target of the declared member. |
None
|
|
after
|
Optional name of the body member the |
None
|
|
kind
|
The usage kind the |
'action'
|
|
multiplicity
|
Optional bracketed source-end multiplicity |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a text argument is not a string. |
ValueError
|
If both or neither of |
add_accept ¶
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 |
True
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
|
after
|
Optional body member to insert after. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string or |
ValueError
|
If |
add_send ¶
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 |
True
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
|
after
|
Optional body member to insert after. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string or |
ValueError
|
If |
add_assign ¶
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 |
True
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
|
after
|
Optional body member to insert after. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string or |
ValueError
|
If |
add_if ¶
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 |
required | |
else_body
|
Optional else-branch |
None
|
|
then
|
Whether to prefix the statement with |
True
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
|
after
|
Optional body member to insert after. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string, |
ValueError
|
If |
add_while ¶
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 |
required | |
until
|
Optional post-condition expression. |
None
|
|
then
|
Whether to prefix the statement with |
True
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
|
after
|
Optional body member to insert after. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string, |
ValueError
|
If |
add_loop ¶
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 |
required | |
until
|
Optional post-condition expression. |
None
|
|
then
|
Whether to prefix the statement with |
True
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
|
after
|
Optional body member to insert after. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string, |
ValueError
|
If |
add_for ¶
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 |
required | |
type
|
Optional loop-variable type. |
None
|
|
then
|
Whether to prefix the statement with |
True
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
|
after
|
Optional body member to insert after. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string, |
ValueError
|
If |
add_terminate ¶
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 |
True
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
|
after
|
Optional body member to insert after. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string or |
ValueError
|
If |
add_guarded_then ¶
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 ¶
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 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 a require constraint to a requirement-like body.
add_assume_constraint ¶
Add an assume constraint to a requirement-like body.
add_connection ¶
Add a connection-like usage between two feature references.
add_allocation ¶
Add an allocation ... allocate from_ to to usage.
add_succession ¶
Add a succession ... first from_ then to usage.
delete ¶
Delete a declaration, optionally removing declarations that refer to it.
move ¶
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; |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Editor |
self, so operations can be chained |
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_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 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_action_def ¶
Add an action def with input and output parameters.
add_action ¶
Add an action with input and output parameters.
add_perform_action ¶
Add a perform action name : Type usage (SysML v2 7.17.6).
add_perform ¶
Add a perform <action>; usage naming an existing action usage;
the member is named by the action it references.
add_exhibit ¶
Add an exhibit <state>; usage named by its referenced state.
add_state_action ¶
Add an entry, do or exit action to a state body.
add_constraint_def ¶
Add a constraint def; expression= writes { … } while
value= writes a feature value with = ….
add_constraint ¶
Add a constraint; expression= writes { … } while
value= writes a feature value with = ….
add_assert_constraint ¶
Add an asserted constraint usage, optionally negated.
add_assert ¶
Add an anonymous assert usage; the assertion is not named by ref.
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") ... )
add_first ¶
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 |
add_then ¶
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 |
None
|
|
action
|
The member name, mutually exclusive with |
None
|
|
type
|
Optional type of the declared action member. |
None
|
|
kind
|
Declared member kind, defaulting to |
'action'
|
|
multiplicity
|
Optional bracketed source-end multiplicity |
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 ¶
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'
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string. |
add_accept ¶
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 |
None
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string. |
ValueError
|
If |
add_send ¶
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 |
None
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string. |
ValueError
|
If |
add_assign ¶
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 |
None
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string. |
ValueError
|
If |
add_if ¶
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 |
required | |
else_body
|
Optional else-branch |
None
|
|
then
|
Whether to prefix the item with |
None
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string or body is not a
|
ValueError
|
If |
add_while ¶
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 |
required | |
until
|
Optional post-condition expression. |
None
|
|
then
|
Whether to prefix the item with |
None
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string or |
ValueError
|
If |
add_loop ¶
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 |
required | |
until
|
Optional post-condition expression. |
None
|
|
then
|
Whether to prefix the item with |
None
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string or |
ValueError
|
If |
add_for ¶
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 |
required | |
type
|
Optional loop-variable type. |
None
|
|
then
|
Whether to prefix the item with |
None
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string or |
ValueError
|
If |
add_terminate ¶
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 |
None
|
|
multiplicity
|
Optional source-end multiplicity, emitted with |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If a notation argument is not a string. |
ValueError
|
If |
add_guarded_then ¶
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 |
add_else ¶
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 |
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 |
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 |
save ¶
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
|
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.
|
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 ¶
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 ¶
opensysml.OwnerNotNamespaceError ¶
opensysml.IllegalMemberKindError ¶
opensysml.MemberNameTakenError ¶
opensysml.DeleteReferencedError ¶
opensysml.OwnerInsideTargetError ¶
opensysml.MoveReferencedError ¶
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 ¶
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 ¶
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 |
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; |
instances |
list[Instance]
|
The objects the call reported: the one this
verdict is about ( |
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 ( |
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 |
question |
str
|
The question the verdict answers: 'evaluate' for an
evaluation; reported by a service advertising
|
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 |
requirement_id
property
¶
FQN of the requirement a satisfaction verdict asserts satisfied.
instance_path
property
¶
Path from the validated object to the one this verdict is about.
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 |
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 |
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 |
standing |
Standing
|
The engine that ran the case, the strength of its
evidence and the bounds it ran under; unreported when the service
predates |
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 |
result |
What it computed, or None when |
|
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, |
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
|
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
|
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 |
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; |
summary |
Verdict
|
The object's own verdict, of kind 'object': holds
when every assertion does, carries |
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 |
valid
property
¶
Whether the object is shown valid: at least one assertion, every one holding, and every held object reached.
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
|
requirement_id
property
¶
FQN of the requirement this verdict was reported for, if any.
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_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 |
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 |
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 |
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 |
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: |
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 |
authority |
str
|
The strongest evidence it may claim, one of |
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
|
|
protocol |
str
|
How it is spoken to: |
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 |
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 |
strength |
str
|
One of the |
bounds |
tuple
|
The bounds the engine ran under, each marked when it stopped at it |
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. |
properties |
Dict[str, str]
|
The selected properties it has. A property an element does not have is absent rather than empty. |
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 |
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, |
document_name
property
¶
The name diagnostics report this document under: the path or name.
file
classmethod
¶
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 content, reported and indexed under name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name diagnostics report the content under, such as
|
required |
content
|
str
|
The model source |
required |
language
|
str
|
|
None
|
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
|
|
time |
Quantity | int | float
|
The instant the record was written at, in the runtime clock's
unit — a |
object |
Optional[ObjectRef]
|
The object the record is about; |
machine |
str
|
The state machine the record is about, as
|
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 |
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 |
version |
int
|
The version of the form, its |
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 |
cells |
tuple
|
One value sequence per column, in column order |
verdict |
Optional[DocumentVerdict]
|
The |
object |
Optional[ObjectRef]
|
The |
state |
Optional[DocumentState]
|
The |
event |
Optional[DocumentEvent]
|
The |
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 ( |
name |
str
|
The active leaf state's own name ( |
path |
str
|
The leaf's path from the machine's top level ( |
state |
Optional[ElementRef]
|
The state usage's declaration |
region |
str
|
The orthogonal region declaring the leaf ( |
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 |
kind |
str
|
|
text |
str
|
The assertion as written ( |
path |
str
|
The object checked, named from the element the query was bound
to ( |
status |
str
|
|
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 ( |
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 |
path |
str
|
The object by the label a session reaches it under: the
qualified name it was instantiated as ( |
element |
Optional[ElementRef]
|
The usage the object is held under, its definition or usage; reported when answered, ignored when bound |