Skip to main content

Getting Started


The following documentation is presented as Python code running inside a Jupyter Notebook. To run it yourself you can copy/type each individual cell or directly download the full notebook, including all required files.

Here we'll show a series of examples of what the Treble Software Development Kit (SDK) can be used for. The examples are based on Jupyter Notebooks but it is by no means necessary to use the SDK within a Notebook style environment. It is, however, a convenient way to do initial scripting, especially while getting a feeling for the SDK.

The initial notebooks are self-standing but can be viewed as a step-by-step guide to run your first simulation.

Initialize SDK and Create a Project


Before initializing the SDK, you will need to put your credential file to the correct directory. When you receive access to the SDK, you will be provided with instructions of how to do this.

The TSDK (Treble SDK) is what is used to initialize your SDK instance.

# Import the SDK class.
from treble_tsdk.tsdk import TSDK
# The tsdk_namespace provides convenient access to most SDK classes/variables.
# Here we import the tsdk_namespace as 'treble'.
from treble_tsdk import tsdk_namespace as treble
# The display_data module provides functions that can be used to display many SDK datastructures as trees or tables.
# Here we import the display_data module as 'dd'.
from treble_tsdk import display_data as dd

# Initialize the SDK (for this you will need credentials)
tsdk = TSDK()

When you create a SDK object the SDK will load your credentials and check if there are any updates available to the SDK package. We strongly recommend that you try and keep your SDK package up-to-date if possible.

Working with Projects


At the top of the organizational hierarchy for each organization are the projects. The projects own simulations, models and Geometries. The data belonging to a project is all linked to the project in the cloud.

Projects belong to your organization so users belonging to the same organization can collaborate on a project.

Each project has a unique ID and a unique name. The instance of the TSDK class has a few functions to work with projects.

  • create_project(name) - Create a project with a certain name (id will be generated).
  • get_project(id) - Load a project with a certain id.
  • get_project_by_name(name) - Load a project with a certain name.
  • get_or_create_project(name) - Create a project if no project exists with that name, otherwise load the last updated project with that name.
  • get_last_updated_project() - Load the project you were using last time
  • list_projects() - List all projects in your organization
  • list_my_projects() - List all projects created by you as a user
  • delete_project(id) - Delete the project with this id

We will load or create new project with the name Tutorial

project_name = "Tutorial"
p = tsdk.get_or_create_project(name=project_name, description="Project used in Documentation Tutorial")

A good way to get an overview of your projects, and to associate ids with project names and creation dates. It's a good idea to plot the list of projects as a table. The id can then be used to load a certain project.

projects = tsdk.list_projects()
dd.as_table(projects)

This Tutorial project is then what the next notebooks will all use.