1+ """
2+ Daytona REPL environment that runs Python code in Daytona sandboxes.
3+
4+ Uses the Daytona API (https://daytona.io/docs) for sandbox management.
5+ """
6+
17import base64
28import json
39import textwrap
915 CreateSandboxFromImageParams ,
1016 Daytona ,
1117 DaytonaConfig ,
18+ Image ,
1219 Resources ,
1320 SessionExecuteRequest ,
1421)
2229# =============================================================================
2330
2431
25- def get_default_image () -> dict :
32+ def get_default_image () -> Image :
2633 """
27- Build a default Daytona image specification with common libraries for data science,
34+ Build a default Daytona image with common libraries for data science,
2835 math, and general Python work.
2936 """
30- return {
31- "base_image" : "python: 3.11-slim" ,
32- "system_packages" : [
33- "build-essential" ,
34- " git" ,
35- " curl" ,
36- " wget" ,
37- " libopenblas-dev" ,
38- " liblapack-dev" ,
39- ],
40- "python_packages" : [
37+ return (
38+ Image . debian_slim ( " 3.11" )
39+ . run_commands (
40+ "apt-get update && apt-get install -y build-essential \
41+ git \
42+ curl \
43+ wget \
44+ libopenblas-dev \
45+ liblapack-dev" ,
46+ )
47+ . pip_install (
4148 # Data science essentials
4249 "numpy>=1.26.0" ,
4350 "pandas>=2.1.0" ,
@@ -57,8 +64,8 @@ def get_default_image() -> dict:
5764 "regex>=2023.0.0" ,
5865 # For state serialization
5966 "dill>=0.3.7" ,
60- ],
61- }
67+ )
68+ )
6269
6370
6471# =============================================================================
@@ -317,7 +324,7 @@ def __init__(
317324 memory : int = 2 ,
318325 disk : int = 5 ,
319326 auto_stop_interval : int = 0 ,
320- image : dict | None = None ,
327+ image : Image | None = None ,
321328 lm_handler_address : tuple [str , int ] | None = None ,
322329 context_payload : dict | list | str | None = None ,
323330 setup_code : str | None = None ,
@@ -335,7 +342,7 @@ def __init__(
335342 memory: Memory in GB for the sandbox.
336343 disk: Disk space in GB for the sandbox.
337344 auto_stop_interval: Minutes of inactivity before auto-stop. 0 = run indefinitely.
338- image: Image specification dict for declarative building. If None, uses default image.
345+ image: Daytona Image object for declarative building. If None, uses default image.
339346 lm_handler_address: (host, port) tuple for LM Handler server.
340347 context_payload: Initial context to load into the environment.
341348 setup_code: Optional code to run during setup.
0 commit comments