Skip to main content
Skip table of contents

Python Engine

Now users can run their python script within valispace to perform some computations through python coding similar to the octave engine. Additionally, this also allows users to access the rest and do modifications to the objects individually or in bulk. The inbuilt python engine currently supports Valispace packages, pint and Scipy (includes NumPy and others). Since the Python engine is developed recently, only a few packages are available in the beta feature.

Python Script flow in Scripting Module

The typical workflow in a scripting module involving the python engine is shown in the image below. In case the user doesn't want to perform a calculation and do some bulk changes through the rest API, the user can write the python code directly and run the script.

Packages within python Engine

Since we implemented the python engine within valispace as a beta feature, the python engine doesn’t support all the packages. Currently, very few packages are supported. The packages with are currently supported are

  • Valispace => 0.1.16 # Valispace API

  • Pint => 0.18 # Python Library used for Scientific units

  • SciPy =>1.7.3 #python library to define, operate and manipulate physical quantities(includes NumPy and others)

Example for the python scripting

With the python engine, the user can add the inputs and output and can write a python code to compute the results. This is similar to how it works in an octave engine. In the below example, we have added a small example on how you can write the python script to add a component to component.

from typing import Any, Dict

import valispace

def main(**kwargs) -> Dict[str, Any]:
    This is the main function to execute your script and it must exists.

    Other functions and files can be also created. You have at your disposal
    to import Valispace API, scipy, numpy and pint.

    :param kwargs: Dictionary with data received from Valispace.
    :type kwargs: Dict[str, Any]

    :return: Dictionary with data to send back to Valispace.
    :rtype: Dict[str, Any]
    # TODO: Write your code here
valispace = valispace.API(url="", username = "", password = "") #add your deployment name, username and the password

# The ID of the Parent Component; If it is at the highest level, parent is null, but project need to be specified.
parent_component = 57111

# Object with the new Component Property
component = {
	"name": "NewCompentName2",
	"parent": parent_component

# Function to get Vali by the fullname
componentPosted ="components/", component)

Currently to access the valispace rest API, the user has to provide the login information. That means the password will be visible to others. We are aware that this is inconvenient to use. Therefore to avoid this, We recommend users to create a test user with a common password so the users can use the python engine to test/run the scripts.

The login information is only needed if you are accessing the REST API. This will be improved in the future.

Few use cases that you can perform with the scripting in the beta feature version of the scripting module

  • Creating a vali and adding it to multiple existing components

  • Make bulk edits to the identifiers of requirements

  • Run a simulation using python

  • Convert the units of all power valis to kW

Few use cases that you can perform with the scripting in the future with the python engine of the scripting module

  • Creating and running a script to export the hierarchy of components

  • Creating an export as ReqIF format from the valispace requirements

  • Create a bill of materials extracting components’ material, component number, mass, cost

  • Import or export of requirements from/to excel

  • Export of requirements to templates through the word exporter

Since we are testing this feature, we are releasing as a beta feature with limited functionality. In the future, we are looking forward for creating a repository where users can access some of the common scripts and can copy, edit based on their use case and run them within their deployment. If you are interested, you can also share your scripts to us and we add them in the common repository.

To improve this functionality, we would require your suggestions/improvements. Feel free to drop us your suggestions/feedback to

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.