| name | vastai-local-dev-loop |
| description | Configure Vast.ai local development with testing and fast iteration.
Use when setting up a development environment, testing instance provisioning,
or building a fast iteration cycle for GPU workloads.
Trigger with phrases like "vastai dev setup", "vastai local development",
"vastai dev environment", "develop with vastai".
|
| allowed-tools | Read, Write, Edit, Bash(vastai:*), Bash(pip:*), Bash(docker:*), Grep |
| version | 1.11.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","vast-ai","testing","workflow"] |
| compatibility | Designed for Claude Code, also compatible with Codex and OpenClaw |
Vast.ai Local Dev Loop
Overview
Set up a fast, reproducible local development workflow for Vast.ai GPU workloads. Test Docker images locally, mock API responses for CI, and minimize cloud GPU costs during development.
Prerequisites
- Completed
vastai-install-auth setup
- Docker installed locally
- Python 3.8+ with pytest
Instructions
Step 1: Project Structure
vastai-project/
src/
vastai_client.py # API client wrapper
job_runner.py # Job orchestration logic
instance_manager.py # Instance lifecycle management
docker/
Dockerfile # GPU workload image
requirements.txt # Python dependencies for GPU job
tests/
test_client.py # Unit tests with mocked API
test_job_runner.py # Integration tests
conftest.py # Shared fixtures and mocks
scripts/
test-connection.sh # Quick API verification
benchmark-gpu.py # GPU benchmark script
.env.development # Dev API key (low spending limit)
.env.production # Prod API key (gitignored)
Step 2: Mock the Vast.ai API for Testing
import pytest
from unittest.mock import MagicMock
@pytest.fixture
def mock_vast_client():
client = MagicMock()
client.search_offers.return_value = {
"offers": [
{"id": 12345, "gpu_name": "RTX_4090", "gpu_ram": 24,
"dph_total": 0.22, "reliability2": 0.99,
"inet_down": 500, "ssh_host": "test.host", "ssh_port": 22},
]
}
client.create_instance.return_value = {"new_contract": 67890}
client.show_instances.return_value = [
{: , : ,
: , : }
]
client