Skip to main content

tsdk

TSDKCredentials Objects

class TSDKCredentials()

TSDK credentials container. Credentials can be stored

__init__

def __init__(client_id: str,
client_secret: str = None,
environment: str = None)

Creates a TSDKCredentials container. This class can either be initialized by supplying a TSDK credentials string or

client_id and client_secret variables. F.ex:

  • cred = TSDKCredentials("bG9vayBhdCB5b3UsIGhhY2tlcg==")
  • cred = TSDKCredentials("my client_id", "my client_secret")

Arguments:

  • client_id: client_id or credentials string
  • client_secret: if client_id is provided then client_secret is required.
  • environment: Environment should be set if using client_id+client_secret and connecting to a specific environment.

from_file

@staticmethod
def from_file(cred_file_path: str) -> "TSDKCredentials"

Load TSDKCredentials container from a credentials file.

Arguments:

  • cred_file_path: Path to TSDK .cred file.

TSDK Objects

class TSDK()

__MaterialLibrary Objects

class __MaterialLibrary()

get_by_id

@lru_cache(20)
def get_by_id(id: str) -> MaterialDto

Get material by id.

Arguments:

  • id: Id of material.

Returns:

MaterialDto: MaterialDto object.

get_by_name

@lru_cache(20)
def get_by_name(name: str) -> MaterialDto

Get material by name.

Arguments:

  • name (str): Name of material to fetch.

Returns:

MaterialDto: MaterialDto object.

get_by_category

@lru_cache(5)
def get_by_category(category: str = None) -> List[MaterialDto]

Get materials by category.

Arguments:

  • category (str): Optional, filter results by material category.

Returns:

list[MaterialDto]: Returns a list of MaterialDtos.

get

@lru_cache(5)
def get(category: str = None) -> List[MaterialDto]

Get materials.

Arguments:

  • category (str): Optional, filter results by material category.

Returns:

list[MaterialDto]: Returns a list of MaterialDtos.

get_categories

@lru_cache(1)
def get_categories() -> List[str]

Get available material categories.

Returns:

list[str]: Returns a list of category names as strings.

get_categories_with_count

def get_categories_with_count() -> List[CategoryInfoDto]

Get all categories and the number of materials in that category.

Returns:

Dict[str,int]: Dictionary where the category name is the key and number of materials in that category is the value.

__GeometryLibrary Objects

class __GeometryLibrary()

query

def query(
name: str = None,
tag: str = None,
category: GeometryLibraryCategory = None) -> List[GeometryLibraryObj]

Query the Geometry library by name, tag, category or fetch all available geometries.

Arguments:

  • name: If provided the library will filter by geometry name.
  • tag: If provided the library will filter by geometry tag.
  • category: If provided the library will filter by geometry category.

Returns:

list[GeometryObj]: Returns a list of GeometryObjects.

get_categories

@lru_cache(1)
def get_categories() -> List[str]

Get available geometry library categories.

Returns:

List[str]: Returns a list of category names.

get_categories_with_count

def get_categories_with_count() -> List[CategoryInfoDto]

Get all categories and the number of geometries in that category.

Returns:

Dictionary where the category name is the key and number of geometries in that category is the value.

download

def download(id: str, destination_file: str)

Download geometry model file.

Arguments:

  • id (str): Id of geometry to download.
  • destination_file (str): Destination file path

get_overview

def get_overview(filter_user: str = False) -> OverviewDto

Get a report of running/queued simulations.

Arguments:

  • filter_user: If true then it will only show/report the simulations the logged in user has created.

create_project

def create_project(name: str, description: str = None) -> Project

Create a TSDK Project.

Projects are used to organize simulation, each simulation belong to a project. The project, and its associated simulations, can later be accessed with the method get_project()

Arguments:

  • name (str): Name of the project
  • description (str): A short description of the project, defaults to None

Returns:

Project: A Project object which can be used to add simulations to

get_project

def get_project(project_id: Union[ProjectDto, str]) -> Project

Get the project with the associated id, from the project object

you can access the simulations which belong to that project.

To find the project id, you can run list_projects() and for the relevant entry you can access the id instance attribute of the project

Arguments:

  • id (str): The unique id of the requested

Returns:

Project: A class instance of Project, containing the requested project

get_last_updated_project

def get_last_updated_project() -> ProjectDto

Returns:

ProjectDto: Returns last updated project along with its simulations.

list_projects

def list_projects(client_id: str = None) -> List[ProjectDto]

Listing the projects with information useful to identify the project which

is of interest. Each element of the list is an object containing information about the associated project. Elements of the list can be queried to access information such as the ids of the projects

Arguments:

  • client_id (str): Optional parameter, returns only projects created by the user with the given client_id

Returns:

list[ProjectDto]: Returns a list of ProjectDtos.

list_my_projects

def list_my_projects() -> List[ProjectDto]

List all projects created by the logged in user

Returns:

list[ProjectDto]: Returns a list of ProjectDtos.

delete_project

def delete_project(id: str)

Remove a project from the record. Be careful not to delete anything you are not

sure you want to delete

Arguments:

  • id (str): The id of the project you want to delete

get_or_create_project

def get_or_create_project(name: str, description: str = None) -> Project

Looks for a project with the given name, if it's not found it will create the project

Arguments:

  • name str - project name
  • description str, optional - description of the project. Defaults to None.

Returns:

  • Project - loaded or new project