-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_daytona.py
More file actions
42 lines (32 loc) · 1.22 KB
/
Copy pathtest_daytona.py
File metadata and controls
42 lines (32 loc) · 1.22 KB
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
"""Test Daytona with real API key"""
import os
from pathlib import Path
# Load environment variables
env_path = Path(__file__).parent / ".env"
if env_path.exists():
for line in env_path.read_text().splitlines():
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
os.environ[key.strip()] = value.strip()
from daytona import Daytona, DaytonaConfig
print("Testing Daytona Sandbox...")
print(f"API Key: {os.getenv('DAYTONA_API_KEY')[:20]}...")
try:
# Initialize with API key
config = DaytonaConfig(api_key=os.getenv('DAYTONA_API_KEY'))
daytona = Daytona(config)
print("Creating sandbox...")
sandbox = daytona.create()
print(f"✓ Sandbox created: {sandbox.id if hasattr(sandbox, 'id') else 'OK'}")
print("Running code...")
response = sandbox.process.code_run('print("Hello from Daytona!")')
print(f"✓ Exit code: {response.exit_code}")
print(f"✓ Output: {response.result}")
print("Cleaning up...")
daytona.delete(sandbox)
print("✓ Sandbox deleted")
print("\n✅ Daytona integration working!")
except Exception as e:
print(f"✗ Error: {e}")
import traceback
traceback.print_exc()