SDKs
Python API
Managing Tensor One Resources via SDK.
This document outlines the core functionalities provided by the Tensor One Python SDK, including how to interact with endpoints, manage templates, and list available GPUs. These operations allow you to dynamically manage computational resources within the Tensor One environment.
Get Endpoints
Retrieve a list of all available endpoint configurations.
import tensorone
import os
tensorone.api_key = os.getenv("TENSORONE_API_KEY")
# Fetching all available endpoints
endpoints = tensorone.get_endpoints()
print(endpoints)
Create a Template
Create a new template by specifying a name and Docker image.
import tensorone
import os
tensorone.api_key = os.getenv("TENSORONE_API_KEY")
try:
new_template = tensorone.create_template(
name="test",
image_name="tensorone/base:0.1.0"
)
print(new_template)
except tensorone.error.QueryError as err:
print(err)
print(err.query)
Create an Endpoint
Create a new endpoint with a specific template and GPU configuration.
import tensorone
import os
tensorone.api_key = os.getenv("TENSORONE_API_KEY")
try:
new_template = tensorone.create_template(
name="test",
image_name="tensorone/base:0.4.4",
is_serverless=True
)
print(new_template)
new_endpoint = tensorone.create_endpoint(
name="test",
template_id=new_template["id"],
gpu_ids="AMPERE_16",
workers_min=0,
workers_max=1,
)
print(new_endpoint)
except tensorone.error.QueryError as err:
print(err)
print(err.query)
Get Available GPUs
List all available GPUs for endpoint allocation.
import tensorone
import json
import os
tensorone.api_key = os.getenv("TENSORONE_API_KEY")
gpus = tensorone.get_gpus()
print(json.dumps(gpus, indent=2))
Get GPU by ID
Retrieve details of a specific GPU using its ID.
import tensorone
import json
import os
tensorone.api_key = os.getenv("TENSORONE_API_KEY")
gpu = tensorone.get_gpu("NVIDIA A100 80GB PCIe")
print(json.dumps(gpu, indent=2))
Through these functionalities, the Tensor One Python SDK enables efficient and flexible management of compute resources to support a wide range of project needs.