API

pytrio.RestClient

class RestClient:
    def __init__(self)

RestClient handles REST API operations. Create it with ServiceClient.create_rest_client().

import pytrio as trio

client = trio.ServiceClient()
rest_client = client.create_rest_client()

# List weights
weights = rest_client.list_user_checkpoints().result()

# List training runs
runs = rest_client.list_training_runs().result()

Methods

list_user_checkpoints

def list_user_checkpoints(
    self,
    limit: int = 100,
    offset: int = 0,
) -> ConcurrentFuture[CheckpointsListResponse]

List model weights for the current user with pagination.

Parameters

ParameterTypeDefaultDescription
limitint100Number of items to return
offsetint0Pagination offset

Returns

ConcurrentFuture[CheckpointsListResponse] - call .result() to get the weight list and pagination metadata.

Example

checkpoints = rest_client.list_user_checkpoints(limit=100, offset=0).result()

get_checkpoint_archive_url

def get_checkpoint_archive_url(
    self,
    checkpoint_id: str,
) -> ConcurrentFuture[CheckpointArchiveUrlResponse]

Get a temporary download URL for a model weight.

Parameters

ParameterTypeDescription
checkpoint_idstrModel weight ID from list_user_checkpoints

Returns

ConcurrentFuture[CheckpointArchiveUrlResponse] - call .result() to get the response containing the temporary download URL.

Example

url_info = rest_client.get_checkpoint_archive_url(checkpoint_id="abc123").result()

get_training_run

def get_training_run(self, training_run_id: str) -> ConcurrentFuture[TrainingRun]

Get details for one training run.

Parameters

ParameterTypeDescription
training_run_idstrTraining run ID

Returns

ConcurrentFuture[TrainingRun] - call .result() to get the training-run details.

Example

run = rest_client.get_training_run(training_run_id="run-001").result()

list_training_runs

def list_training_runs(self, limit: int = 20, offset: int = 0) -> ConcurrentFuture[TrainingRunsResponse]

List training runs for the current user with pagination.

Parameters

ParameterTypeDefaultDescription
limitint20Number of items to return
offsetint0Pagination offset

Returns

ConcurrentFuture[TrainingRunsResponse] - call .result() to get the training-run list and pagination metadata.

Example

runs = rest_client.list_training_runs(limit=10, offset=0).result()

list_checkpoints

def list_checkpoints(self, training_run_id: str) -> ConcurrentFuture[CheckpointsListResponse]

List all checkpoints under a training run.

Parameters

ParameterTypeDescription
training_run_idstrTraining run ID

Returns

ConcurrentFuture[CheckpointsListResponse] - call .result() to get the checkpoint list and pagination metadata.

Example

checkpoints = rest_client.list_checkpoints(training_run_id="run-001").result()

delete_checkpoint

def delete_checkpoint(
    self,
    training_run_id: str,
    checkpoint_id: str,
) -> ConcurrentFuture[None]

Delete a checkpoint under a training run.

Parameters

ParameterTypeDescription
training_run_idstrTraining run ID
checkpoint_idstrCheckpoint ID

Example

rest_client.delete_checkpoint(training_run_id="run-001", checkpoint_id="ckpt-step100").result()

get_session

def get_session(self, session_id: str) -> ConcurrentFuture[GetSessionResponse]

Get information about one session.

Parameters

ParameterTypeDescription
session_idstrSession ID

Returns

ConcurrentFuture[GetSessionResponse] - call .result() to get session details.

Example

session = rest_client.get_session(session_id="sess-abc").result()

list_sessions

def list_sessions(self, limit: int = 20, offset: int = 0) -> ConcurrentFuture[ListSessionsResponse]

List sessions for the current user with pagination.

Parameters

ParameterTypeDefaultDescription
limitint20Number of items to return
offsetint0Pagination offset

Returns

ConcurrentFuture[ListSessionsResponse] - call .result() to get the session list and pagination metadata.

Example

sessions = rest_client.list_sessions().result()

get_sampler

def get_sampler(self, sampler_id: str) -> APIFuture[GetSamplerResponse]

Get information about one sampler.

Parameters

ParameterTypeDescription
sampler_idstrSampler ID

Returns

APIFuture[GetSamplerResponse] - call .result() or await it to get sampler details.

Example

sampler = rest_client.get_sampler(sampler_id="sampler-xyz").result()
Was this documentation helpful?

On this page