Skip to main content

Provides access to Capella MBSE projects in Python

Project description

PyPI - Python Version https://github.com/DSD-DBS/py-capellambse/actions/workflows/code-qa.yml/badge.svg License REUSE status https://img.shields.io/badge/code%20style-black-000000.svg https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336

A Python 3 headless implementation of the Capella modeling tool

Intro

capellambse allows you reading and writing Capella models from Python without Java or the Capella tool on any (reasonable) platform. We wanted to “talk” to Capella models from Python, but without any Java on the way. We thought this project will help individuals and organisations getting through the MBSE adoption journey with Capella faster and so we made it public and open-source.

With capellambse you can access all (or almost all) Capella model elements, and render diagrams as SVG and PNG. We made it for automation of Systems Engineering work, so it integrates nicely into most CI/CD toolchains. We also found it at the core of our artifact generation pipelines (model to documents, model to SW interfaces).

The library works with PVMT and Requirements extensions without any additional efforts.

It started as a basic library somewhere mid 2019. Since then it was re-architected a few times and now has a full read/write capability for most of the present Capella ontology. We are continuously improving the API (introducing shortcuts), increasing the meta-model coverage and have more engineering automations and improvements in the pipeline to share.

Documentation and examples

The library is designed to be easy to use and discover, especially in an interactive environment such as JupyterLab. Additionally, API documentation is automatically generated and published whenever new features and bug fixes are added.

You are encouraged to explore our test models and demo notebooks. Click on the button below to launch a Jupyter notebook server on the public myBinder service, and get started in seconds:

https://mybinder.org/badge_logo.svg

Warning: Do not enter confidential information, such as passwords for non-public models, into a notebook hosted on myBinder. If you want to try out capellambse with those models, please install and run it in a local, trusted environment!

The docs/source/examples directory contains several hands-on example notebooks that you can immediately run and start experimenting with. Below is a short summary of each notebook’s goal. If you are in the JupyterLab environment, you can click the notebook names to directly open them in a new lab tab. On Github, you will be shown a statically rendered preview of the notebook.

  • 01 Introduction.ipynb provides a high-level overview of the library features. It visualizes examples like a Component - Function allocation table by leveraging Jupyter’s and IPython’s rich display functionality.

  • 02 Intro to Physical Architecture.ipynb explores some more advanced concepts on the example of the Physical Architecture Layer. It shows how to derive tabular data, like a Bill of Materials or a Software to Hardware allocation table, by using pandas dataframes.

  • 03 Data Values.ipynb shows how the API can be used to explore classes, class instances and other objects related to data modeling.

  • 04 Intro to Jinja templating.ipynb demonstrates how to effectively combine capellambse with the powerful Jinja templating engine. This enables the creation of all sorts of model-derived documents and artifacts, including interactive web pages, PDF documents and any other textual representations of your models.

  • 05 Introduction to Libraries.ipynb shows how to use Capella Library Projects within capellambse. In this example you’ll learn how the API can be used to open a project that is based on a library and find objects in both models.

  • 06 Introduction to Requirement access and management.ipynb shows how the API can be used to work with requirements objects, introduced by the Capella Requirements Viewpoint. In this example you’ll see how to find requirements in the model, see which objects requirements are linked / traced to and even export requirements to Excel or ReqIF formats.

  • 07 Code Generation.ipynb shows how to generate code from class diagrams. In particular, we focus on Interface Descriptive Languages with concrete examples for Class to ROS2 IDL and Google Protocol Buffers. We also show how simple Python stubs could be generated given a Class object.

  • 08 Property Values.ipynb shows how to access property values and property value groups, as well as the Property Value Management (PVMT) extension.

  • 09 Context Diagrams.ipynb shows the capellambse-context-diagrams extension that visualizes contexts of Capella objects. The extension is external to the capellambse library and needs to be installed separately.

  • 10 Declarative Modeling.ipynb demonstrates a basic application of the declarative approach to modeling on a coffee machine example.

  • 11 Complexity Assessment.ipynb quickly demonstrates how to use and view the model complexity badge for a Capella model.

We are constantly working on improving everything shown here, as well as adding even more useful functionality and helpful demos. If you have any new ideas that were not mentioned yet, don’t hesitate to contribute!

Installation

In order to use private models that are not publicly available, please install and use capellambse in a local, trusted environment.

You can install the latest released version directly from PyPI.

pip install capellambse

To set up a development environment, clone the project and install it into a virtual environment.

git clone https://github.com/DSD-DBS/py-capellambse
cd capellambse
python -m venv .venv

source .venv/bin/activate.sh  # for Linux / Mac
.venv\Scripts\activate  # for Windows

pip install -U pip pre-commit
pip install -e '.[docs,test]'
pre-commit install

We recommend developing within a local Jupyter notebook server environment. In order to install and run it in the same virtual environment, execute the following additional commands:

pip install jupyter capellambse
cd docs/source/examples
jupyter-notebook

If your browser did not open automatically, follow the instructions in the terminal to start it manually.

Once in the browser, simply click on the 01 Introduction.ipynb notebook to start!

Current limitations

We are continuously improving coverage of Capella onthology with our high-level API (the current coverage map is available here), however it is still incomplete. It covers most of the commonly used paths but when you need to get to an ontology element that isnt covered yet you may do so by using the low-level API.

Also, as we started in mid 2019 and there was no such thing as Python4Capella yet, we are not API compatible with that project. However, we intend to add API compatibility with Python4Capella in later releases.

The generated diagrams are currently not persisted in .aird files, and currently there is no plan to implement this. If there is a genuine usecase for that we may re-consider it - feel free to create an issue or add comments to an existing one.

Render diagrams in untrusted jupyter notebooks

The SVG format relies on a stylesheet, however in untrusted notebooks any stylesheets are stripped. As a workaround we support the PNG format. For this the cairosvg library is needed which depends on additional libraries. See the official CairoSVG documentation for detailed instructions.

Contributing

We’d love to see your bug reports and improvement suggestions! Please take a look at our guidelines for contributors for details.

Licenses

This project is compliant with the REUSE Specification Version 3.0.

Copyright DB Netz AG, licensed under Apache 2.0 (see full text in LICENSES/Apache-2.0.txt)

Dot-files are licensed under CC0-1.0 (see full text in LICENSES/CC0-1.0.txt)

To provide the same look and feel across platforms, we distribute our library bundled with the OpenSans font (capellambse/OpenSans-Regular.ttf). The OpenSans font is Copyright 2020 The Open Sans Project Authors, licensed under OFL-1.1 (see full text in LICENSES/OFL-1.1.txt).

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

capellambse-0.5.36.dev7.tar.gz (5.6 MB view details)

Uploaded Source

Built Distribution

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

capellambse-0.5.36.dev7-py3-none-any.whl (344.9 kB view details)

Uploaded Python 3

File details

Details for the file capellambse-0.5.36.dev7.tar.gz.

File metadata

  • Download URL: capellambse-0.5.36.dev7.tar.gz
  • Upload date:
  • Size: 5.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for capellambse-0.5.36.dev7.tar.gz
Algorithm Hash digest
SHA256 7d6109ecd348ae0de7a2bc472512f2014069618fc78766fec81c6d14290ae6f1
MD5 de192404c214b9d1a319d59ad4ef4e34
BLAKE2b-256 12244da8d7b5b6e28707c1c086a496bd3573abb2a346d5f82d35752bc5303b98

See more details on using hashes here.

File details

Details for the file capellambse-0.5.36.dev7-py3-none-any.whl.

File metadata

File hashes

Hashes for capellambse-0.5.36.dev7-py3-none-any.whl
Algorithm Hash digest
SHA256 d16204508fe98c88164ffd4d6b39af1303c0057104d074fa18c473b95ee03166
MD5 3e03b6f32504716283b27072d3a80225
BLAKE2b-256 1707bc07239e42e670c321ba7a24b0fa9a1fe9ee0fadb93881adcd7c6c721c2d

See more details on using hashes here.

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