File size: 3,864 Bytes
fff13d1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Blaxel Sandbox Quick Start

Quick reference for deploying and using the custom Manim + FFmpeg sandbox.

## Prerequisites

```bash
# Install Blaxel CLI
npm install -g @blaxel/cli

# Login to Blaxel
bl login

# Set environment variables
export BLAXEL_API_KEY="your_api_key_here"
```

## One-Command Deployment

```bash
# Automated deployment (recommended)
./deploy_sandbox.sh
```

This will:
- βœ… Check prerequisites
- βœ… Build Docker image locally
- βœ… Test the image
- βœ… Deploy to Blaxel
- βœ… Update your .env file

## Manual Deployment Steps

### 1. Build & Test Locally

```bash
# Build the image
docker build -f Dockerfile.sandbox -t manim-sandbox .

# Run locally
docker run -d --name manim-sandbox-test -p 8080:8080 manim-sandbox

# Test the API
curl -X POST http://localhost:8080/process \
  -H "Content-Type: application/json" \
  -d '{"command": "manim --version", "waitForCompletion": true}'

# Clean up
docker stop manim-sandbox-test && docker rm manim-sandbox-test
```

### 2. Deploy to Blaxel

```bash
# Deploy
bl deploy

# Check status
bl get sandboxes

# Get your image ID
bl get sandbox manim-sandbox -ojson | jq -r '.[0].spec.runtime.image'
```

### 3. Configure Your App

Add to `.env`:
```bash
MANIM_SANDBOX_IMAGE=blaxel/your-workspace/manim-sandbox:latest
BLAXEL_API_KEY=your_api_key_here
```

## Common Commands

### Managing Sandboxes

```bash
# List all sandboxes
bl get sandboxes

# Get specific sandbox
bl get sandbox <name>

# Delete a sandbox
bl delete sandbox <name>

# Connect to sandbox terminal
bl connect sandbox <name>
```

### Testing Your Deployment

```bash
# Test Manim in deployed sandbox
bl connect sandbox your-sandbox-name
# Then inside the sandbox:
manim --version
python3 -c "import manim; print(manim.__version__)"
```

### Viewing Logs

```bash
# View deployment logs
bl logs

# Watch sandbox status
bl get sandbox <name> --watch
```

## Usage in Python

```python
import os
from blaxel.core import SandboxInstance

# Get image from environment
MANIM_SANDBOX_IMAGE = os.getenv("MANIM_SANDBOX_IMAGE")

# Create sandbox
sandbox = await SandboxInstance.create({
    "name": "my-render-job",
    "image": MANIM_SANDBOX_IMAGE,
    "memory": 4096,
})

# Execute Manim render
result = await sandbox.process.exec({
    "command": "manim -qm scene.py MyScene",
    "wait_for_completion": True,
    "timeout": 600000,  # 10 minutes
})

# Clean up
await SandboxInstance.delete("my-render-job")
```

## Troubleshooting

### "Image not found"
```bash
# Verify deployment
bl get sandboxes

# Redeploy if needed
bl deploy
```

### "Authentication failed"
```bash
# Re-login
bl login

# Verify
bl whoami
```

### "Sandbox creation timeout"
```bash
# Increase timeout in code or try different region
sandbox = await SandboxInstance.create({
    "name": "my-render-job",
    "image": MANIM_SANDBOX_IMAGE,
    "memory": 4096,
    "region": "us-east-1",  # Try different region
})
```

### Local Docker issues
```bash
# Check Docker is running
docker info

# View build logs
docker build -f Dockerfile.sandbox -t manim-sandbox . 2>&1 | tee build.log

# Test entrypoint
docker run --rm manim-sandbox cat /entrypoint.sh
```

## Performance Tips

1. **Reuse sandboxes** for multiple renders
2. **Set TTL policies** to auto-cleanup
3. **Adjust memory** based on animation complexity
4. **Use lower quality** for testing

## Resource Limits

| Setting | Recommended | Maximum |
|---------|-------------|---------|
| Memory | 4096 MB | 8192 MB |
| Timeout | 600s (10min) | Varies |
| Quality | medium | production_quality |

## Next Steps

- Run your first animation: `python main_new.py`
- Launch Gradio UI: `python app.py`
- Read full guide: `BLAXEL_SANDBOX_SETUP.md`

## Support

- πŸ“š [Blaxel Docs](https://docs.blaxel.ai)
- πŸ’¬ [Blaxel Discord](https://discord.gg/blaxel)
- πŸ› [Report Issues](https://github.com/your-repo/issues)