Truss Transfer: Baseten Pointer Resolution Utility

0.0.41 · active · verified Thu Apr 16

Truss-transfer is a Python-optional download utility library for resolving Baseten Pointers (bptr), designed to speed up file transfers within the Baseten ecosystem. It is primarily used internally by the `truss` CLI for serving AI/ML models in production. The current stable version is 0.0.41, with frequent releases often coinciding with updates to the main `truss` library.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to define `PyModelRepo` objects, which are central to `truss-transfer`'s functionality. These objects specify how to fetch model artifacts from sources like Hugging Face or Google Cloud Storage, often managed as Baseten Pointers (bptr) for deployment with the main `truss` library.

import truss_transfer
import os

# Example: Define a Hugging Face model repository using PyModelRepo
# For actual use, 'hf_access_token' would be an environment variable or Baseten secret.
# Replace 'your-hf-model' with an actual model ID and 'main' with a valid revision.
hf_model_repo = truss_transfer.PyModelRepo(
    repo_id=os.environ.get('HF_MODEL_ID', 'microsoft/DialoGPT-medium'),
    revision=os.environ.get('HF_MODEL_REVISION', 'main'),
    volume_folder='dialogpt_model_cache',
    runtime_secret_name='hf_access_token'
)

print(f"Defined Hugging Face model repository: {hf_model_repo.repo_id}")

# Example: Define a GCS model repository
# 'gcs-service-account-jsn' would be a Baseten secret containing GCS service account JSON.
gcs_model_repo = truss_transfer.PyModelRepo(
    repo_id=os.environ.get('GCS_BUCKET_PATH', 'gs://my-bucket/my-model/'),
    revision='',
    volume_folder='gcs_model_cache',
    runtime_secret_name='gcs-service-account-jsn',
    kind='gcs'
)

print(f"Defined GCS model repository: {gcs_model_repo.repo_id}")

# In a typical Truss deployment, these PyModelRepo objects are often used
# within a `config.yaml` or a `model.py` for model loading and data transfer.
# This example primarily shows how to instantiate the objects.

view raw JSON →