preview Labs

Module implementing various proposals for how to make the Syside API more convenient and easier to pick up.

Index

Classes

LockedModel

A SysML v2/KerML model interface. Top level elements (typically Packages) can be accessed through the lookup method, e.g. model.lookup("PackageName"). To create a new top level package use the new_top_level_package method.

UnlockedModel

A SysML v2/KerML model that needs to be locked before access.

Functions

empty_model

Opens an empty model, loading only standard library elements (unless include_stdlib=False).

open_model

Opens a model stored in paths, which can be given as a (combination of) file and directory paths. By default the model is allowed to generate warnings (warnings_as_errors) but is not allowed to contain errors (allow_errors).

open_model_unlocked

Opens a model stored in paths, which can be given as a (combination of) file and directory paths. By default the model is allowed to generate warnings (warnings_as_errors) but is not allowed to contain errors (allow_errors).


󰊕 Functions

empty_model(*, warnings_as_errors: bool = False, allow_errors: bool = False, include_stdlib: bool = True, environment: syside.Environment | None = None) syside.preview.LockedModel

Opens an empty model, loading only standard library elements (unless include_stdlib=False).

unlock the returned model before sharing between threads (and re-lock before use), or use a with-block to automatically unlock when exiting the block.

Parameters:
  • warnings_as_errors – if True, warnings are treated errors

  • allow_errors – if True, tries to return a partial or invalid model even in the presence of errors

  • include_stdlib – if False, tries to load the model without also loading the SysML v2 standard library

  • environment – The environment to be used for the model. If this parameter is None, the default environment is used.

Returns:

a LockableModel representing an empty model.

open_model(paths: pathlib.Path | str | Iterable[pathlib.Path | str], *, warnings_as_errors: bool = False, allow_errors: bool = False, include_stdlib: bool = True, environment: syside.Environment | None = None) syside.preview.LockedModel

Opens a model stored in paths, which can be given as a (combination of) file and directory paths. By default the model is allowed to generate warnings (warnings_as_errors) but is not allowed to contain errors (allow_errors).

unlock the returned model before sharing between threads (and re-lock before use), or use a with-block to automatically unlock when exiting the block.

Parameters:
  • paths – path or sequence of paths (given as str or Path) of source files, or directories containing source files, to be included in the model

  • warnings_as_errors – if True, warnings are treated errors

  • allow_errors – if True, tries to return a partial or invalid model even in the presence of errors

  • include_stdlib – if False, tries to load the model without also loading the SysML v2 standard library

  • environment – The environment to be used for the model. If this parameter is None, the default environment is used.

Returns:

a LockableModel representing the model loaded from source files given in paths

Raises:

syside.ModelError – if model contains errors and allow_errors is False

open_model_unlocked(paths: pathlib.Path | str | Iterable[pathlib.Path | str], *, warnings_as_errors: bool = False, allow_errors: bool = False, include_stdlib: bool = True, environment: syside.Environment | None = None) syside.preview.UnlockedModel

Opens a model stored in paths, which can be given as a (combination of) file and directory paths. By default the model is allowed to generate warnings (warnings_as_errors) but is not allowed to contain errors (allow_errors).

lock the returned model before access

Parameters:
  • paths – path or sequence of paths (given as str or Path) of source files, or directories containing source files, to be included in the model

  • warnings_as_errors – if True, warnings are treated errors

  • allow_errors – if True, tries to return a partial or invalid model even in the presence of errors

  • include_stdlib – if False, tries to load the model without also loading the SysML v2 standard library

  • environment – The environment to be used for the model. If this parameter is None, the default environment is used.

Returns:

an UnlockedModel representing the model loaded from source files given in paths

Raises:

syside.ModelError – if model contains errors and allow_errors is False