syside
Native Syside module for Python.
Internally, Syside uses snake_case for all non-type symbols, e.g. attributes and
functions, whereas the specification and the Pilot implementation both use camelCase
instead. snake_case was chosen because it integrates far better into Python -
the programming language that Syside uses.
Additionally, Syside does not use multiple inheritance to implement the standard model
and instead uses sum-types where appropriate (typing.Union in Python). This improves
performance as methods and attributes can be inlined and are not required to be accessed
through interfaces (no pointer chasing), reduces memory usage as unused members need not
be stored (e.g. Relationship interface for Associations), and improves usability
by allowing more flexible constraints on element types.
Usability is further improved by storing child elements in separate members based on
their position in the textual syntax. This is in comparison to the Pilot implementation,
which only uses two such members, ownedRelationship and ownedRelatedElement.
Syside implementation allows direct access to most special members without resorting to
filtering every time, improving performance. Moreover, modifying and inserting such
members does not require potentially expensive reshuffling of children arrays.
Lastly, because textual source files may contain syntax errors, all model elements may return optional elements, even if the corresponding attribute in the specification expects a non-null element. This also allows elements to be default constructible.
Additional Notes
For performance reasons, elements and their groups are stored as specific members in AST nodes based on their position in textual syntax which also makes mutation easier. Notably:
prefixes- group for metadata prefixes, prefixed with#in textual notationheritage- type specializations and conjugationstype_relationships- non-specialization type relationships appearing after specialization part, including feature chainingchildren- elements in the children block (in-between brackets{and}) in textual notation, and expression argumentsdeclared_ends,declared_messages- end features and messages before the children block. In the textual syntax they appear in the same position, hence in contrast to similar groups there are additionaltry_appendandtry_insertmethods that returnNonewithout throwing if modification failed because the slot is already occupied by either ends or messages.
Due to parser limitations, argument member references are parsed as argument members instead. This has little effect on analysis as intermediate
FeatureReferenceExpressionandOwningMembershipare excluded from the expression tree.Elements can only be owned nodes in the same document to satisfy tree constraints, elements can be referenced by any appropriate element. Violating this constraint raises
ValueError. Similarly, trying to steal ownership also raisesValueError.Relationship ends cannot generally be modified unless they are member elements, and only a few allow this dependent on the textual syntax (KerML only but there are currently no checks that models constructed are actually representable in chosen textual syntax beyond some simple checks during printing).
Model Modifications
Adding new owned or referenced Elements to a model can raise:
TypeError:if the relationship type is not allowed by the container/setter as this violates internal invariants.
if the element type is not allowed by the container/setter as this violates internal invariants.
if the element type is not allowed by the relationship as this violates internal invariants.
if the element is owned but the relationship instead only references related element to prevent orphan elements.
ValueError:if taking ownership of an element from another document as this violates internal invariants.
if stealing ownership of the element as there is no good default behaviour on what should happen, remove the element from the model first before trying to re-parent it.
RuntimeError:if the parent
Elementhas been removed from the model. This can be fixed by adding theElementback into the model as an owned element.
Index
Submodules
Structured access to Syside version |
||
Various debugging related utilities. |
||
Internal GC interface. |
||
Submodule for IDE related functions. |
||
Labs |
Umbrella submodule for all experimental implementations. |
|
Internal CLI exposed to Python. |
||
Labs |
Convenience module intending to match the standard library |
|
Labs |
Module implementing various proposals for how to make the Syside API more convenient and easier to pick up. |
|
Labs |
Syside Automator ReqIF import/export. |
Classes
A context manager for managing lock acquiry and release. |
||
A mutex-protected data |
||
An IP version 4 style address. |
||
An IP version 6 style address. |
||
Percent-encoding options |
||
|
||
Strongly typed CST symbol id |
||
Strongly typed CST field id |
||
Strongly typed CST state id |
||
A CST node |
||
Utf-8 based text position |
||
Utf-16 based text position |
||
Utf-32 based text position |
||
Utf-8 based text range |
||
Utf-16 based text range |
||
Utf-32 based text range |
||
Utf-8 based text edit |
||
Utf-16 based text edit |
||
Utf-32 based text edit |
||
Data used to initialize new text documents with. |
||
A subset of |
||
A basic text document that holds source text and allows conversions between encoded text positions and byte offsets. |
||
A textual edit applicable to a text document. |
||
A thread-safe registry for |
||
Strongly typed numerical document id |
||
Strongly typed numerical library id |
||
Utf-8 based segment into a source text document. |
||
Represents a related message and source code location for a diagnostic. |
||
Additional diagnostics context information for formatting. |
||
Diagnostic formatting style options |
||
Structure to capture a description for an error code. |
||
LSP compatible diagnostic structure. |
||
Signifies an error when attempting to schedule documents for analysis |
||
A schedule for parsing and analysis of documents. |
||
Options for a particular |
||
An IO schedule that can be executed concurrently on an |
||
A language agnostic multithreaded parsing and analysis pipeline. |
||
The collection of all diagnostics for a single document. |
||
Stage times for a single document. |
||
Total times for each pipeline stage. |
||
Schedule execution result |
||
Thread-pool executor used to run various multi-threaded tasks internally. |
||
The base type of all documents corresponding to a single source file. |
||
Document version |
||
Options to construct new document with |
||
KerML and SysML specific document type |
||
A cheap-to-construct marker for infinity ( |
||
A cheap-to-constructor surrogate for metadata features |
||
Cache of standard library elements used by sema. |
||
Messages emitted during compilation or evaluation. |
||
A non-recursive compiler/virtual machine for KerML and SysML expressions. |
||
A statically indexed symbol |
||
A static thread-safe index that allows multiple entries using the same name |
||
Options for |
||
A base type for all internally-iterated objects. |
||
A type-erased iterable |
||
An immutable view into a native random-access container. Implements Sequence protocol. |
||
A sequence of qualified name segments that stringifies with unrestricted names as needed. |
||
A sequence of path segments that stringifies with unrestricted names as needed. |
||
The basic type of all AST nodes. |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
An internally iterated generator for |
||
A |
||
A view to a container of children nodes. |
||
Container that stores a vector of children nodes. |
||
Container that stores a vector of potentially owned children nodes. |
||
Container that stores a vector of children nodes that may own feature chainings. |
||
Container for relationship bodies. Works similarly to |
||
An accessor for dependency |
||
An accessor for specific member elements |
||
An accessor for specific owned member elements |
||
A typed accessor for some parameter members |
||
An accessor for potentially unowned member features that may be also chained |
||
A generic accessor for references in the model |
||
An accessor for reference that may also be chained |
||
An accessor for ends in connector declarations |
||
An accessor for feature reference expression referent member |
||
A typed accessor for satisfaction subject of |
||
A convencience accessor for instantiation arguments. |
||
A typed accessor for unowned member elements |
||
A typed accessor for flow payload features |
||
A typed accessor for function and expression result members |
||
A typed accessor for various parameter members |
||
A typed accessor for potentially unowned member features that may be also chained |
||
A typed accessor for feature value members |
||
A typed accessor for some reference usage members |
||
A typed accessor for parameter expression members |
||
A typed accessor for parameter action bodies |
||
A typed accessor for multiplicity range bounds expression |
||
A typed accessor for transition triggers |
||
A typed accessor for transition guards |
||
A typed accessor for transition effects |
||
A typed accessor for transition succession |
||
A typed accessor for multiplicity in |
||
A typed accessor for some owned member features |
||
A typed accessor for target feature member in feature chain expressions |
||
A typed accessor for transition source |
||
A typed accessor for type reference |
||
A typed accessor for feature reference |
||
A typed accessor for classifier reference |
||
An accessor for ends in |
||
An accessor for ends in |
||
An accessor for messages in |
||
A typed accessor for type reference that may also be chained |
||
A typed accessor for feature reference that may also be chained |
||
An accessor for dependency metadata prefixes |
||
An accessor for namespace metadata prefixes |
||
An accessor for namespace body |
||
An accessor for annotating element annotations |
||
An accessor for type specializations and conjugations |
||
An accessor for type and feature relationships that are part of the declaration |
||
A recursive depth-first tree iterator to (in)direct heritage relationships. |
||
A |
||
The type used in a type check expression, e.g. |
||
Options for S-exp output |
||
An opaque reference print function that will be called only for synthetic references. |
||
Pretty-printer for KerML/SysML models back to textual syntax. |
||
Formatting options for pretty-printed models |
||
Semantic resolver for SysML. This is responsible for linking references and resolving semantic rules in the pipeline. |
||
An error signifiying that a different reference was found while attempting to revert changes made by sema, and requiring manual intervention. |
||
Abstract base class for serialization writer implementations. |
||
Message emitted during (de)serialization |
||
(De)Serialization report containing emitted messages. |
||
Options for SysML model serialization. Attribute options are ordered in descending precedence. |
||
Serializer for SysML models. The actual serialization output depends on used |
||
Options for serialization writer to JSON strings |
||
Serialization writer that outputs JSON string |
||
Internal opaque type for deserialization attribute mapping |
||
Reference that has yet to be linked. |
||
Deserializer for SysML models. The actual deserialization input depends on used |
||
|
||
The model as it was deserialized, with references potentially unresolved. |
||
Abstract base class for all deserialization readers. |
||
Unbound reader for JSON deserialization |
||
An exception thrown when model contains errors. |
||
Standard library environment for use with user models. |
||
A SysMLv2 model represented using abstract syntax. |
||
A SysMLv2 model represented using abstract syntax. |
||
A diagnostic providing information about a model. |
||
All model diagnostics. |
Attributes
|
Generic type variable |
|
|
Generic covariant type variable |
|
|
Generic |
|
|
Generic type variable |
|
|
Generic |
|
|
Generic |
|
|
Marker to signal the deserializer that attributes are using internal names (snake_case). |
|
|
Marker to signal the deserializer that attributes are using standard names (camelCase). |
|
A scalar value in SysML. |
||
Expression evaluation result type. |
Functions
Construct a |
||
Decode a filesystem path from a |
||
Format diagnostics to string. |
||
Creates a combined pipeline for parsing and analysing both KerML and SysML documents. |
||
Generate a minimal S-expression of owned elements rooted at |
||
Prints model subtree starting at |
||
Collect and cache symbols exported by |
||
Build the AST for |
||
Reset semantic state of |
||
Convenience function for serialization. Prefer using |
||
Convenience function for deserialization. Prefer using |
||
Precompute element IDs for a given |
||
Load a SysMLv2 model. |
||
Load a SysMLv2 model. |
||
Recursively collect all |
||
Get a default initialized |
Enumerations
A known URL scheme. |
||
The type of host in a URL. |
||
Document build state |
||
The state of a document inside of a pipeline. |
||
A document tier. |
||
Represents reasons why a text document is saved. |
||
The severity of the diagnostic |
||
Kind of glyphs to insert when formatting related information tree |
||
Cost threshold of validation rules to execute. |
||
An implicit specialization kind that also depends on the type of the element. |
||
A strongly typed explicit visitation operation |
||
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
SysML |
Implementation of |
|
Operator that can be declared explicitly, e.g. excluding |
||
Any operator, including implicit operators |
||
Language used to parse/build the model |
||
Semantic resolution state of |
||
The identifier used to reference the element in the textual syntax. |
||
Syntax mode to print the model into. |
||
Preference for selecting identifiers when printing synthetic references. |
||
Possible formatted line endings |
||
Action taken when a serialization error is encountered. |
||
Is this a model-created document? |
Attributes
- T = TypeVar("T")
Generic type variable
- U = TypeVar("U", covariant=True)
Generic covariant type variable
- TNode = TypeVar("TNode", bound=syside.AstNode)
Generic
AstNodetype variable
- TElement = TypeVar("TElement", bound=syside.Element)
Generic type variable
- R = TypeVar("R", bound=syside.Relationship)
Generic
Relationshiptype variable
- M = TypeVar("M", bound=syside.Element)
Generic
Elementtype variable
- DESERIALIZE_INTERNAL: syside.AttributeMap = Ellipsis
Marker to signal the deserializer that attributes are using internal names (snake_case).
- DESERIALIZE_STANDARD: syside.AttributeMap = Ellipsis
Marker to signal the deserializer that attributes are using standard names (camelCase).
- type Scalar = int | float | bool | syside.Infinity | str | syside.Element | syside.BoundMetaclass | complex | fractions.Fraction
A scalar value in SysML.
May be:
int,float,bool,strfrom literal expressions, or expressions evaluated as suchInfinityfrom literal expressionsElementfrom reference or chain expressionsBoundMetaclassfrom metadata access expressionscomplexfrom complex functions and operator expressions with complex numbersFractionfrom rational functions, operator expressions with rational numbers, and integer division
- type Value = Scalar | range | list[Scalar] | None
Expression evaluation result type.
May be:
a
Scalarvalue from compatible expressionsNonefrom null expressions, or expressions evaluated as suchrangefrom range operator expressionslist[Scalar]from sequence expressions. Note that sequences are always flattened
Functions
- make_file_url(arg0: str, options: syside.EncodingOpts = ...) syside.Url
Construct a
Urlfor a filesystem path with thefile:scheme.This correctly handles Windows and Posix paths, normalizes Windows drive letters to uppercase, and percent escapes Unicode characters.
- make_file_url(arg0: str | os.PathLike[AnyStr], options: syside.EncodingOpts = ...) syside.Url
- decode_path(arg0: syside.Url, options: syside.EncodingOpts = ...) str
Decode a filesystem path from a
Url.This correctly handles Windows and Posix paths using
file://scheme and returns otherUrlsas is.
- format_diagnostics(errors: Sequence[syside.Diagnostic], context: syside.DiagnosticContext = ..., options: syside.DiagnosticFormatOptions = ...) str
Format diagnostics to string.
contextwill be used to add additional contextual information, like source snippets, to the formatted output.optionscontrol how the diagnostics are formatted.Note that this is subject to change in future releases.
- make_pipeline(arg: syside.PipelineOptions, /) syside.Pipeline
Creates a combined pipeline for parsing and analysing both KerML and SysML documents.
- sexp(root: syside.Element, options: syside.SexpOptions = ...) str
Generate a minimal S-expression of owned elements rooted at
root, useful for debugging.
- sexp(root: syside.Element, indent: int = 2, include_implicit: bool = True, print_references: bool = False) str
- pprint(arg0: syside.Element, printer: syside.ModelPrinter | None = None, config: syside.PrinterConfig = ...) str
Prints model subtree starting at
rootto textual syntax.NOTE This performs very little checking that the given model can be represented in textual syntax, besides checking for elements that are missing. This has no effect when used as a formatter on a model parsed without syntax errors but programmatic models are not guaranteed to be valid textual syntax. In addition, it does not check that references are reachable from their scopes so parsing the printed model can fail to find them again. Otherwise, clearly unreachable references, such as when one of their ancestors is anonymous, will raise errors.
Only the first import from any parent namespaces that would shorten the printed reference is used. This does not apply to imports themselves to prevent reference resolution errors due to multiple or cyclical imports. Additionally, references relative to left-hand side expression result types, such as those from
FeatureChainExpressions, are assumed to be directly or indirectly accessible so only their short or regular name is printed.
- collect_exports(document: syside.Document) int
Collect and cache symbols exported by
document. This must be called before thedocumentis indexed, otherwise wrong or no symbols may be indexed. Returns the number of symbols cached.
- build_model(document: syside.Document, language: syside.ModelLanguage | None = None) list[syside.Diagnostic]
Build the AST for
documentfrom itstext_document.Any existing model will be cleared, and the built model will not have its references linked. Instead, most references will use placeholder references that will be replaced by actual targets in linking stage. Only
sysmlandkermllanguages are supported.This is a CST -> AST stage in the pipeline.
Raises
ValueErrorif thedocumenthas unsupported language, or it has no associatedtext_document.
- sema_reset(element: syside.Element) None
Reset semantic state of
element.This will typically remove any implied relationships, and reverse a few other changes made by sema. After this completes,
element.sema_state == SemaState.None.
- sema_reset(document: syside.Document, reporter: Callable[[syside.Element, syside.UnexpectedDifferentReference], None] | None = None) None
Reset semantic state of
document.This will call
sema_reseton all owned elements, and additionally reset all resolved references back to unresolved state. While resetting references, if the resolved reference does not match the current reference,reporterwill be called with the element the reference applies to andUnexpectedDifferentReferencethat was found. By default,reporterwill print such errors tostderr.After this completes,
document.build_state == BuildState.Indexed.
- serialize(root: syside.Element, writer: syside.Writer[syside.T], options: syside.SerializationOptions = ...) syside.SerdeReport[syside.Element]
Convenience function for serialization. Prefer using
Serializerto avoid allocations when doing repeated serializations.
- serialize(root: syside.Element, writer: syside.Writer[syside.T], use_standard_names: bool = True, include_derived: bool = False, include_redefined: bool = False, include_default: bool = False, include_optional: bool = False, include_implied: bool = False, fail_action: syside.FailAction = FailAction.Diagnose, filter: syside.CompilerFilter | Callable[[syside.Element, list[syside.Expression]], bool] | None = None) syside.SerdeReport[syside.Element]
- deserialize(document: syside.Document, reader: syside.Reader, attributes: syside.AttributeMap) tuple[syside.DeserializedModel, syside.SerdeReport[syside.DocumentSegment | str | syside.Element]]
Convenience function for deserialization. Prefer using
Deserializerto avoid allocations when doing repeated deserializations.
- precompute_element_ids(arg: syside.Document | syside.Element, /) None
Precompute element IDs for a given
DocumentorElementsubtree.This has complexity
O(n)for number of elements irrespective of tree depth and number of owned elements, and is far more efficient than generating element IDs lazily throughElement.element_id. Consider precomputing element IDs for documents that will be serialized to improve performance.A similar precomputation is performed on serialization, however its results are not persisted to the elements.
- try_load_model(paths: Iterable[str | os.PathLike[Any]], *, environment: syside.Environment | None = None, sysml_source: str | None = None, kerml_source: str | None = None, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
- try_load_model(paths: Iterable[str | os.PathLike[Any]], environment: syside.Environment) tuple[syside.Model, syside.Diagnostics]
- try_load_model(*, sysml_source: str, kerml_source: str | None = ..., environment: syside.Environment | None = None, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
- try_load_model(*, kerml_source: str, sysml_source: str | None = ..., environment: syside.Environment | None = None, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
Load a SysMLv2 model.
At least one of
paths,sysml_source, andkerml_sourcemust not be none.- Parameters:
paths – The paths to SysMLv2 or KerML files to load. These files must have correct file extensions (
.sysmlor.kerml).environment – The environment to be used for the model. If this parameter is left to
None, uses the default environment.sysml_source – A SysMLv2 source to be loaded as an in-memory file.
kerml_source – A KerML source to be loaded as an in-memory file.
attach_comments – if
True, source notes are attached to the model and preserved on formatting the model back to text
- Returns:
Model and Diagnostics pair. Note that models may only be partial if parsing failed, however even a partial model may be of interest for analysis.
- load_model(paths: Iterable[str | os.PathLike[Any]], *, environment: syside.Environment | None = None, sysml_source: str | None = None, kerml_source: str | None = None, warnings_as_errors: bool = False, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
- load_model(*, sysml_source: str, kerml_source: str | None = ..., environment: syside.Environment | None = None, warnings_as_errors: bool = False, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
- load_model(*, kerml_source: str, sysml_source: str | None = ..., environment: syside.Environment | None = None, warnings_as_errors: bool = False, attach_comments: bool = False) tuple[syside.Model, syside.Diagnostics]
Load a SysMLv2 model.
At least one of
paths,sysml_source, andkerml_sourcemust not be none.- Parameters:
paths – The paths to SysMLv2 or KerML files to load. These files must have correct file extensions (
.sysmlor.kerml).environment – The environment to be used for the model. If this parameter is left to
None, uses the default environment. sysml_source: A SysMLv2 source to be loaded as an in-memory file. kerml_source: A KerML source to be loaded as an in-memory file.attach_comments – if
True, source notes are attached to the model and preserved on formatting the model back to text
- Returns:
Model and Diagnostics pair.
- Raises:
ModelError – If returned diagnostics contain errors, or if
warnings_as_errorsisTrue, if diagnostics contain errors or warnings.
- collect_files_recursively(directory_path: str | os.PathLike[Any]) list[pathlib.Path]
Recursively collect all
.sysmland.kermlfiles in the specified directory.
- get_default_executor(threads: int | None = None) syside.Executor
Get a default initialized
Executorfor running schedules. Default executor will use half the logical cores that are available on the current machine. An executor is just a thread pool so there is no reason for constructing and destroying one all the time.The first time this is called,
threadsargument will be used to initialize the executor with the given number of threads. Subsequent calls will be no-ops andthreadswill be ignored.
Enumerations
- class Scheme
A known URL scheme.
noneIndicates that no scheme is present
UnknownIndicates the scheme is not a well-known scheme
FtpFile Transfer Protocol (FTP)
FTP is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network.
FileFile URI Scheme
The File URI Scheme is typically used to retrieve files from within one’s own computer.
HttpThe Hypertext Transfer Protocol URI Scheme
URLs of this type indicate a resource which is interacted with using the HTTP protocol.
HttpsThe Secure Hypertext Transfer Protocol URI Scheme
URLs of this type indicate a resource which is interacted with using the Secure HTTP protocol.
WsThe WebSocket URI Scheme
URLs of this type indicate a resource which is interacted with using the WebSocket protocol.
WssThe Secure WebSocket URI Scheme
URLs of this type indicate a resource which is interacted with using the Secure WebSocket protocol.
Used in
- class HostType
The type of host in a URL.
noneNo host is specified.
NameA host is specified by reg-name.
IPv4A host is specified by ipv4_address.
IPv6A host is specified by ipv6_address.
IPvFutureA host is specified by IPvFuture.
Used in
- class BuildState
Document build state
- class DocumentState
The state of a document inside of a pipeline.
Created= 0
Document has been created
Building= 1
Document is being built
Completed= 2
Document was built successfully
Cancelled= 3
Document building was cancelled
Error= 4
Document building errored
Used in
- class DocumentTier
A document tier.
This is used internally to apply specific optimizations, mainly to standard library sources.
StandardLibraryDocument is a part of standard library. Assume that such documents change very rarely, or only change with new tool versions.
ExternalDocument is imported from a third-party library. Assume that they do not change unless the third-party library is updated.
ProjectDocument is a part of the current project and may be edited at any time.
- class TextDocumentSaveReason
Represents reasons why a text document is saved.
- class DiagnosticSeverity
The severity of the diagnostic
- class TreeDrawing
Kind of glyphs to insert when formatting related information tree
NoNo tree is drawn
AsciiUse ASCII symbols for drawing
UnicodeUse unicode symbols for drawing
Used in
- class ValidationTiming
Cost threshold of validation rules to execute.
OnTypeValidation rules will be executed on every key stroke.
OnSaveValidation rules will be executed on document save.
ManualValidation rules will be executed manually.
NeverNo validation rules will be executed
Used in
- class ImplicitSpecializationKind
An implicit specialization kind that also depends on the type of the element.
Note that not all
(type, kind)combinations are valid.AccessedFeatureActionTransitionAfterAnnotatedElementAssumptionAtBaseBaseTypeBinaryBinaryObjectCaseActorCheckedConstraintClassifierConcernDataValueDecisionDoEffectEnclosedPerformanceEntryExclusiveStateExitFeatureFeatureWriteFlowGuardIfThenElseIncomingTransferLifeLoopVariableMergeMessageNegatedObjectOccurrenceOwnedActionOwnedPerformanceOwnedPortParticipantPayloadPerformedActionPortionRequirementRequirementActorRequirementStakeholderSatisfiedSnapshotSourceOutputStartingAtStateTransitionSubAnalysisCaseSubUseCaseSubVerificationCaseSubactionSubcalculationSubcaseSubitemSubobjectSuboccurrenceSubpartSubperformanceSubportSubrenderingSubrequirementSubstateSubviewTargetTargetInputTimesliceTransitionLinkTriggerVerificationViewRenderingWhen Used in
- class VisitAction
A strongly typed explicit visitation operation
- class FeatureDirectionKind
SysML
Implementation of
FeatureDirectionKinddefined in the KerML specification.Specification:
FeatureDirectionKindenumerates the possible kinds ofdirectionthat aFeaturemay be given as a member of aType.For language description, see section 7.3.4.2 of the KerML specification. For more details on the model, see section 8.3.3.1.5 of the KerML specification.
- class PortionKind
SysML
Implementation of
PortionKinddefined in the SysML specification.Specification:
PortionKindis an enumeration of the specific kinds ofOccurrenceportions that can be represented by anOccurrenceUsage.For language description, see section 7.9.3 of the SysML specification. For more details on the model, see section 8.3.9.5 of the SysML specification.
- class RequirementConstraintKind
SysML
Implementation of
RequirementConstraintKinddefined in the SysML specification.Specification:
A
RequirementConstraintKindindicates whether aConstraintUsageis an assumption or a requirement in aRequirementDefinitionorRequirementUsage.For language description, see section 7.21.2 of the SysML specification. For more details on the model, see section 8.3.21.6 of the SysML specification.
- class StateSubactionKind
SysML
Implementation of
StateSubactionKinddefined in the SysML specification.Specification:
A
StateSubactionKindindicates whether theactionof a StateSubactionMembership is an entry, do or exit action.For language description, see section 7.18.2 of the SysML specification. For more details on the model, see section 8.3.18.3 of the SysML specification.
- class TransitionFeatureKind
SysML
Implementation of
TransitionFeatureKinddefined in the SysML specification.Specification:
A
TransitionActionKindindicates whether thetransition_featureof aTransitionFeatureMembershipis a trigger, guard or effect.For language description, see section 7.18.3 of the SysML specification. For more details on the model, see section 8.3.18.7 of the SysML specification.
- class TriggerKind
SysML
Implementation of
TriggerKinddefined in the SysML specification.Specification:
TriggerKindenumerates the kinds of triggers that can be represented by aTriggerInvocationExpression.For language description, see section 7.18.3 of the SysML specification. For more details on the model, see section 8.3.17.18 of the SysML specification.
- class VisibilityKind
SysML
Implementation of
VisibilityKinddefined in the KerML specification.Specification:
VisibilityKindis an enumeration whose literals specify the visibility of aMembershipof anElementin aNamespaceoutside of thatNamespace. Note that “visibility” specifically restricts whether anElementin aNamespacemay be referenced by name from outside theNamespaceand only otherwise restricts access to anElementas provided by specific constraints in the abstract syntax (e.g., preventing the import or inheritance of privateElements).For language description, see section 7.2.5.2 of the KerML specification. For more details on the model, see section 8.3.2.4.7 of the KerML specification.
- class ExplicitOperator
Operator that can be declared explicitly, e.g. excluding
select.IfNullCoalescingImpliesLogicalOrOrXorLogicalAndAndEqualsSameNotEqualsNotSameIsTypeHasTypeAtAtAtAsMetaLessLessEqualGreaterGreaterEqualRangePlusMinusMultiplyDivideModuloExponentStarExponentCaretConjugationNotAllQuantityComma Used in
- class Operator
Any operator, including implicit operators
IfNullCoalescingImpliesLogicalOrOrXorLogicalAndAndEqualsSameNotEqualsNotSameIsTypeHasTypeAtAtAtAsMetaLessLessEqualGreaterGreaterEqualRangePlusMinusMultiplyDivideModuloExponentStarExponentCaretConjugationNotAllQuantityCommaDotCollectIndexSelect
- class ModelLanguage
Language used to parse/build the model
- class SemaState
Semantic resolution state of
Elements.Sema will use this information to discard duplicate work, e.g. when resolving elements in a group of related documents.
Used in
- class NameID
The identifier used to reference the element in the textual syntax.
This may be used to select the printed identifier for synthetic references when printing the model back to textual syntax.
Used in
- class PrintMode
Syntax mode to print the model into.
Used in
- class NamePreference
Preference for selecting identifiers when printing synthetic references.
AutomaticImplementation defined name preference
RegularPrefer regular name, otherwise fall back to short name
ShortPrefer short name, otherwise fall back to regular name
ShortestPrefer shortest name
LongestPrefer longest name (for completeness)
Used in
- class LineEnd
Possible formatted line endings
Used in
- class FailAction
Action taken when a serialization error is encountered.
- class DocumentKind
Is this a model-created document?
MODELIs this a model-created document?
ENVIRONMENTIs this a model-created document?
ALLIs this a model-created document?
USERIs this a model-created document?
STDLIBIs this a model-created document?
Used in