Retrieve detailed information about a specific template, including full configuration, resources, features, and build information.
Overview
Getting template details helps you:
- View complete template configuration
- Check resource specifications (min/max/default)
- Review available features and capabilities
- Access build information and status
- Verify template availability before use
Template details include more information than the list view, including full configuration, build steps, and organization-specific details.
Get Template by Name
Get detailed information about a specific template:
from hopx_ai import Sandbox
# Get template details
template = Sandbox.get_template("code-interpreter")
print(f"Template: {template.display_name}")
print(f"Name: {template.name}")
print(f"Description: {template.description}")
print(f"Category: {template.category}")
print(f"Language: {template.language}")
print(f"Status: {template.status}")
Resource Specifications
View resource specifications (default, min, max):
from hopx_ai import Sandbox
template = Sandbox.get_template("code-interpreter")
# Default resources
if template.default_resources:
res = template.default_resources
print(f"Default Resources:")
print(f" vCPU: {res.vcpu}")
print(f" Memory: {res.memory_mb}MB")
print(f" Disk: {res.disk_gb}GB")
# Minimum resources
if template.min_resources:
min_res = template.min_resources
print(f"\nMinimum Resources:")
print(f" vCPU: {min_res.vcpu}")
print(f" Memory: {min_res.memory_mb}MB")
print(f" Disk: {min_res.disk_gb}GB")
# Maximum resources
if template.max_resources:
max_res = template.max_resources
print(f"\nMaximum Resources:")
print(f" vCPU: {max_res.vcpu}")
print(f" Memory: {max_res.memory_mb}MB")
print(f" Disk: {max_res.disk_gb}GB")
View template features and tags:
from hopx_ai import Sandbox
template = Sandbox.get_template("code-interpreter")
# Features
if template.features:
print("Features:")
for feature in template.features:
print(f" β’ {feature}")
# Tags
if template.tags:
print("\nTags:")
for tag in template.tags:
print(f" β’ {tag}")
# Popularity
if template.popularity_score:
print(f"\nPopularity Score: {template.popularity_score}")
Template Status and Availability
Check template status and availability:
from hopx_ai import Sandbox
from hopx_ai.errors import NotFoundError
try:
template = Sandbox.get_template("code-interpreter")
print(f"Status: {template.status}")
print(f"Active: {template.is_active}")
print(f"Public: {template.is_public}")
if template.status == "active":
print("β
Template is available for use")
elif template.status == "building":
print("β³ Template is currently being built")
elif template.status == "failed":
print("β Template build failed")
else:
print(f"β οΈ Template status: {template.status}")
except NotFoundError:
print("β Template not found")
Organization-Specific Templates
Check if template is organization-specific:
from hopx_ai import Sandbox
template = Sandbox.get_template("my-custom-template")
if template.organization_id:
print(f"Organization Template: {template.organization_id}")
print("This is a custom template for your organization")
else:
print("Public Template")
print("Available to all users")
Complete Example
Hereβs a complete example showing template details:
from hopx_ai import Sandbox
from hopx_ai.errors import NotFoundError
def show_template_details(template_name: str):
try:
template = Sandbox.get_template(template_name)
print(f"π {template.display_name}")
print(f" Name: {template.name}")
print(f" ID: {template.id}")
print()
if template.description:
print(f"π Description:")
print(f" {template.description}")
print()
print(f"π·οΈ Metadata:")
print(f" Category: {template.category or 'N/A'}")
print(f" Language: {template.language or 'N/A'}")
print(f" Status: {template.status}")
print(f" Active: {template.is_active}")
print(f" Public: {template.is_public}")
print()
if template.default_resources:
res = template.default_resources
print(f"π» Default Resources:")
print(f" vCPU: {res.vcpu}")
print(f" Memory: {res.memory_mb}MB")
print(f" Disk: {res.disk_gb}GB")
print()
if template.min_resources or template.max_resources:
print(f"π Resource Limits:")
if template.min_resources:
min_res = template.min_resources
print(f" Min: {min_res.vcpu}vCPU, {min_res.memory_mb}MB RAM")
if template.max_resources:
max_res = template.max_resources
print(f" Max: {max_res.vcpu}vCPU, {max_res.memory_mb}MB RAM")
print()
if template.features:
print(f"β¨ Features:")
for feature in template.features:
print(f" β’ {feature}")
print()
if template.tags:
print(f"π·οΈ Tags:")
for tag in template.tags:
print(f" β’ {tag}")
print()
if template.docs_url:
print(f"π Documentation: {template.docs_url}")
print()
if template.organization_id:
print(f"π’ Organization: {template.organization_id}")
print(" (Custom template)")
except NotFoundError:
print(f"β Template '{template_name}' not found")
# Show details for a template
show_template_details("code-interpreter")
Best Practices
1. Get Details Before Use
Always get template details to verify resources and features before creating sandboxes.
2. Check Status
Verify template status is βactiveβ before using it to create sandboxes.
3. Review Resources
Check default, min, and max resources to ensure they meet your requirements.
4. Verify Features
Review features list to confirm template has capabilities you need.
5. Handle Not Found
Always handle NotFoundError when getting template details.
Next Steps