Skip to main content

Python runtime and local web viewer for MBSE JSON models.

Project description

MBSE

Python runtime and local web viewer for MBSE JSON models.

Install

pip install mbse

The web viewer requires Graphviz and its dot command on PATH.

# Ubuntu/Debian
sudo apt install graphviz

# macOS
brew install graphviz

On Windows, install Graphviz from its download page and add its bin directory to PATH.

Model Validation And Discovery

Load a project to validate its project document and every recognized MBSE JSON model below project_root. The registry rejects duplicate model ids, multiple contexts, and invalid entrypoints.

from mbse.model.project.project_registry import ProjectRegistry

registry = ProjectRegistry.load("project.json")
models = registry.iterExecutableModels()
print([model.getDocumentId() for model in models])

The registry validates JSON shape. Action-language handlers are normal Python imports and must be available in the active environment when the runtime executes them.

Automated Runtime Tests

from mbse.model.project.project_registry import ProjectRegistry
from mbse.runtime.runtime import Runtime

registry = ProjectRegistry.load("project.json")
runtime = Runtime()
runtime.init(registry)
runtime.play()
runtime.sendEvent("start")  # A declared HSM event.

assert runtime.getState()["id"] == "running"

Use getExecutionLog(), getVariable(), and getState() for assertions. sendEvent() and getState() require an HSM project entrypoint. See the Runtime Layer for stepping and inspection.

Web Viewer

mbse-view project.json --open-browser

Run the packaged elevator example with nested Activity models:

mbse-example-view

The viewer lists every executable model, renders its diagram, and provides events, typed variables, execution logs, model-call stepping, and breakpoints. It is a local debugging tool that listens on 127.0.0.1 by default.

The viewer requires an HSM project entrypoint. Activity models can be rendered, listed, and debugged when called from that entrypoint.

Documentation

Development

python -m venv .venv
source .venv/bin/activate
pip install -e ".[test]"
ruff check .
pytest

VS Code users can run the ✅ Run CI status-bar button to create .venv when needed and execute the same validation steps as CI locally.

Releases

One-Time Setup

Configure a branch protection rule for main that requires pull requests and the CI / test status check before merging. Do not push directly to main.

Configure a PyPI pending publisher with:

  • Project name: mbse
  • GitHub owner: <owner>
  • Repository: <repository>
  • Workflow: release.yml
  • Environment: pypi

Change Flow

  1. Create a branch and open a pull request against main.
  2. Merge only after CI / test passes.

Release Flow

  1. After the release changes are merged, create and push a version tag:
git tag v0.1.0
git push origin v0.1.0

The publish workflow validates, builds, and uploads the package to PyPI. A failed workflow never uploads a package, but does not remove the pushed tag.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mbse-0.1.0.tar.gz (116.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mbse-0.1.0-py3-none-any.whl (116.5 kB view details)

Uploaded Python 3

File details

Details for the file mbse-0.1.0.tar.gz.

File metadata

  • Download URL: mbse-0.1.0.tar.gz
  • Upload date:
  • Size: 116.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mbse-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e1c8ed8a3db7785347d3c416d964b7ebcd7c4199d5a50c894bb6fdd7ca09dd21
MD5 2f0117e816295553621dc252f05d530e
BLAKE2b-256 333c2fa5446668ea87a5832069d4919dab63a7f4aa7d374b51a6286f0bfa644a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mbse-0.1.0.tar.gz:

Publisher: release.yml on FBS93/mbse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mbse-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mbse-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 116.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mbse-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44d2a36ff0d6195efeec03f7d3907c75e097be35a48aebaafa986f7b3c9be4c1
MD5 77e54bef2f2be4983d4b3ec620cfbd7e
BLAKE2b-256 ded7507286ed78215d02bad7b075237c3d3b0a06fa1750f3cad7d8ac8d585542

See more details on using hashes here.

Provenance

The following attestation bundles were made for mbse-0.1.0-py3-none-any.whl:

Publisher: release.yml on FBS93/mbse

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page