treble_tsdk.tsdk¶
Main TSDK module providing authentication and library access.
Provides the TSDK class for authenticating with the Treble API and accessing material, geometry, device, and source directivity libraries.
- class treble_tsdk.tsdk.TSDKCredentials¶
Bases:
objectTSDK credentials container. Credentials can be stored
- exception InvalidEnvironmentNameException¶
Bases:
ExceptionException raised when an invalid environment name is provided.
Valid environments are: local, test, dev, prod.
- __init__(client_id: str, client_secret: str | None = None, environment: str | None = None, is_sso: bool = False)¶
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”)
- Parameters:
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.
- static sso(token: str | None = None) TSDKCredentials¶
Create credentials from SSO token.
- Parameters:
token (str) – SSO token string, or None to read from TSDK_SSO_TOKEN environment variable.
- Returns TSDKCredentials:
Credentials object for SSO authentication.
- static from_file(cred_file_path: str) TSDKCredentials¶
Load TSDKCredentials container from a credentials file. :param cred_file_path: Path to TSDK .cred file.
- class treble_tsdk.tsdk.TSDK¶
Bases:
objectMain SDK client
Provides access to materials, geometries, projects, simulations, and results through organized library interfaces.
- __init__(credentials: TSDKCredentials | None = None)¶
- property collections: CollectionsLibrary¶
Access to the collections library for managing data collections.
- Returns CollectionsLibrary:
Collections library instance.
- preliminary_checks()¶
Run preliminary checks including cache cleanup, rate limits, updates, and terms acceptance.
- check_terms_and_conditions()¶
Verify that the user has accepted the terms and conditions.
- display_user_info()¶
Display current user information including email and organization.
- check_rate_limit() int | None¶
Check current API rate limit status.
- Returns int | None:
Remaining rate limit or None if not available.
- check_for_updates() SdkVersionDto | None¶
Check if SDK updates are available.
- Returns SdkVersionDto | None:
Update information or None if no updates.
- check_status()¶
Check the status of the Treble API service.
- download_update(download_dir: str) str | None¶
Downloads update wheel to the specified directory. Returns the path to the wheel file.
- refresh_authentication(cred: TSDKCredentials | None = None)¶
Re-authenticate the SDK using updated credentials. This method is used with SSO users.
- Parameters:
cred (TSDKCredentials) – Updated credentials to use.
- get_overview(filter_user: str = False) OverviewDto¶
Get a report of running/queued simulations. :param filter_user: If true then it will only show/report the simulations the logged in user has created.
- create_project(name: str, description: str | None = None, metadata: dict[str, str] | ObjectMetadataDto | ObjectMetadata | None = None, tags: list[str] = []) Project | None¶
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()
- get_project(project_id: ProjectDto | str) Project | None¶
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
- get_project_by_name(name: str) Project | None¶
Gets a project by name, if multiple projects match the name the one created the most recently is returned.
- Parameters:
name (str) – Name of project to get.
- Returns:
A Project object, containing the requested project or None if no project is found.
- get_by_name(name: str) Project | None¶
Gets a project by name, if multiple projects match the name the one created the most recently is returned.
- Parameters:
name (str) – Name of project to get.
- Returns:
A Project object, containing the requested project or None if no project is found.
- list_projects() list[Project]¶
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
- Returns list[Project]:
Returns a list of Project objects.
- get_projects() list[Project]¶
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
- Returns list[Project]:
Returns a list of Project objects.
- list_my_projects() list[Project]¶
list all projects created by the logged in user :returns list[Project]: Returns a list of Project objects.
- delete_project(project: Project | str, force: bool = False) bool¶
Remove a project from the record. Be careful not to delete anything you are not sure you want to delete
- Parameters:
id (str) – The id of the project you want to delete
force – If true, the project will be deleted even if it contains running simulations. The simulations will be cancelled.
- get_or_create_project(name: str, description: str | None = None) Project¶
Looks for a project with the given name, if it’s not found it will create the project
- get_project_from_results_directory(results_dir: str | Path) Project | None¶
Get Project object from a results directory.
- Parameters:
results_dir (str|Path) – Path to either a simulation_info json file or a directory that contains previously downloaded simulation results.
- Returns:
Project that the simulation belongs to.
- get_simulation_from_results_directory(results_dir: str | Path) Simulation | None¶
Get Simulation object from a results directory.
- Parameters:
results_dir (str|Path) – Path to either a simulation_info json file or a directory that contains previously downloaded simulation results.
- Returns:
Simulation that the simulation_info belongs to.
- get_results_object_from_results_directory(results_dir: str | Path, results_type: str = None) 'Results' | None¶
Get ResultsObject object from a results directory.
- get_token_status() TokenStatusDto¶
Get current status of tokens available to the user/organization.