Merge pull request #731 from tnfssc/chore/daytona-upgrade

This commit is contained in:
Sharath 2025-06-15 16:32:03 +05:30 committed by GitHub
commit 1018c71a0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 32 additions and 31 deletions

24
backend/poetry.lock generated
View File

@ -551,14 +551,14 @@ files = [
[[package]]
name = "daytona-api-client"
version = "0.20.1"
version = "0.21.0"
description = "Daytona"
optional = false
python-versions = "*"
groups = ["main", "dev"]
files = [
{file = "daytona_api_client-0.20.1-py3-none-any.whl", hash = "sha256:4d5023108013365eba76bd0bd4704f30dee54c13e2ac5b62e8c88bcd4af5db92"},
{file = "daytona_api_client-0.20.1.tar.gz", hash = "sha256:ff2061f7e7dc9c935a9087216600be277cb9cf6b8c1eecdfe333ef30d6b208fd"},
{file = "daytona_api_client-0.21.0-py3-none-any.whl", hash = "sha256:a8ff1f0fb397368dbd6ddb224c28d679e599c657eab2ec5821cf0c972a60229a"},
{file = "daytona_api_client-0.21.0.tar.gz", hash = "sha256:92d591c5a1750a827b5850425ce483441609b72b05d35a618d5353fbbba50bca"},
]
[package.dependencies]
@ -569,14 +569,14 @@ urllib3 = ">=1.25.3,<3.0.0"
[[package]]
name = "daytona-api-client-async"
version = "0.20.1"
version = "0.21.0"
description = "Daytona"
optional = false
python-versions = "*"
groups = ["main", "dev"]
files = [
{file = "daytona_api_client_async-0.20.1-py3-none-any.whl", hash = "sha256:f24e06e3ab6e554214ed064f1b4c8723356c76c14c69de9a73a6cad60a386127"},
{file = "daytona_api_client_async-0.20.1.tar.gz", hash = "sha256:043045cb173b0b53416c19a9e276124a5c4fe14209f409a8572ef1975240e53f"},
{file = "daytona_api_client_async-0.21.0-py3-none-any.whl", hash = "sha256:f5731963d0dd6c1e207b92bdc7f5b59952d3365444bc9dc8b013d77a4dddf377"},
{file = "daytona_api_client_async-0.21.0.tar.gz", hash = "sha256:08a22c0d1616f82efa8d157d7be6c432554fd43d75560725c4e0cef0228607d6"},
]
[package.dependencies]
@ -589,14 +589,14 @@ urllib3 = ">=1.25.3,<3.0.0"
[[package]]
name = "daytona-sdk"
version = "0.20.2"
version = "0.21.0"
description = "Python SDK for Daytona"
optional = false
python-versions = ">=3.7"
groups = ["main", "dev"]
files = [
{file = "daytona_sdk-0.20.2-py3-none-any.whl", hash = "sha256:ec83c6aeb1a712904ebdfc8f56dab8a3b85f92102fc5fc1b0c7ff8a4af79473e"},
{file = "daytona_sdk-0.20.2.tar.gz", hash = "sha256:2796d19ce92cc45a0dd5c62457b4b0147e0e34514ec1d4807e6364bcd213a010"},
{file = "daytona_sdk-0.21.0-py3-none-any.whl", hash = "sha256:927e5a75113b225eee97ec3f68f1ad6bf93b6b7497b069aa0a3cf051a5b2e0dc"},
{file = "daytona_sdk-0.21.0.tar.gz", hash = "sha256:737c657d186a2732218aa9f7107a2a865560b4e5bbbd165b5f4a1949e8feab83"},
]
[package.dependencies]
@ -605,8 +605,8 @@ aiofiles = ">=24.1.0,<24.2.0"
aiohttp = ">=3.12.0,<4.0.0"
aiohttp_retry = ">=2.9.0,<3.0.0"
boto3 = ">=1.0.0,<2.0.0"
daytona_api_client = ">=0.20.1,<0.21.0"
daytona_api_client_async = ">=0.20.1,<0.21.0"
daytona_api_client = ">=0.21.0,<0.22.0"
daytona_api_client_async = ">=0.21.0,<0.22.0"
Deprecated = ">=1.2.18,<2.0.0"
environs = ">=9.5.0,<10.0.0"
httpx = ">=0.28.0,<0.29.0"
@ -3904,4 +3904,4 @@ testing = ["coverage[toml]", "zope.event", "zope.testing"]
[metadata]
lock-version = "2.1"
python-versions = "^3.11"
content-hash = "09a851f3db2d0b1f130405a69c1661c453f82ce23e078256bc6749662af897a7"
content-hash = "99368309d41431f2104a182b680e9361409121e7a6df3ead3f14173dbaf9d066"

View File

@ -41,7 +41,7 @@ exa-py = "^1.9.1"
e2b-code-interpreter = "^1.2.0"
certifi = "2024.2.2"
python-ripgrep = "0.0.6"
daytona_sdk = "^0.20.2"
daytona-sdk = "^0.21.0"
boto3 = "^1.34.0"
openai = "^1.72.0"
nest-asyncio = "^1.6.0"
@ -68,7 +68,7 @@ agentpress = "agentpress.cli:main"
include = "agentpress"
[tool.poetry.group.dev.dependencies]
daytona-sdk = "^0.20.2"
daytona-sdk = "^0.21.0"
[build-system]
requires = ["poetry-core"]

View File

@ -21,7 +21,9 @@ exa-py>=1.9.1
e2b-code-interpreter>=1.2.0
certifi==2024.2.2
python-ripgrep==0.0.6
daytona-sdk==0.20.2
daytona-sdk==0.21.0
daytona-api-client==0.21.0
daytona-api-client-async==0.21.0
boto3>=1.34.0
openai>=1.72.0
nest-asyncio>=1.6.0

View File

@ -1,5 +1,4 @@
from daytona_sdk import Daytona, DaytonaConfig, CreateSandboxParams, Sandbox, SessionExecuteRequest
from daytona_api_client.models.workspace_state import WorkspaceState
from daytona_sdk import Daytona, DaytonaConfig, CreateSandboxFromImageParams, Sandbox, SessionExecuteRequest, Resources, SandboxState
from dotenv import load_dotenv
from utils.logger import logger
from utils.config import config
@ -38,17 +37,17 @@ async def get_or_start_sandbox(sandbox_id: str):
logger.info(f"Getting or starting sandbox with ID: {sandbox_id}")
try:
sandbox = daytona.get_current_sandbox(sandbox_id)
sandbox = daytona.get(sandbox_id)
# Check if sandbox needs to be started
if sandbox.instance.state == WorkspaceState.ARCHIVED or sandbox.instance.state == WorkspaceState.STOPPED:
logger.info(f"Sandbox is in {sandbox.instance.state} state. Starting...")
if sandbox.state == SandboxState.ARCHIVED or sandbox.state == SandboxState.STOPPED:
logger.info(f"Sandbox is in {sandbox.state} state. Starting...")
try:
daytona.start(sandbox)
# Wait a moment for the sandbox to initialize
# sleep(5)
# Refresh sandbox state after starting
sandbox = daytona.get_current_sandbox(sandbox_id)
sandbox = daytona.get(sandbox_id)
# Start supervisord in a session when restarting
start_supervisord_session(sandbox)
@ -91,7 +90,7 @@ def create_sandbox(password: str, project_id: str = None):
logger.debug(f"Using sandbox_id as label: {project_id}")
labels = {'id': project_id}
params = CreateSandboxParams(
params = CreateSandboxFromImageParams(
image=Configuration.SANDBOX_IMAGE_NAME,
public=True,
labels=labels,
@ -108,11 +107,11 @@ def create_sandbox(password: str, project_id: str = None):
"CHROME_DEBUGGING_HOST": "localhost",
"CHROME_CDP": ""
},
resources={
"cpu": 2,
"memory": 4,
"disk": 5,
},
resources=Resources(
cpu=2,
memory=4,
disk=5,
),
auto_stop_interval=15,
auto_archive_interval=24 * 60,
)
@ -133,7 +132,7 @@ async def delete_sandbox(sandbox_id: str):
try:
# Get the sandbox
sandbox = daytona.get_current_sandbox(sandbox_id)
sandbox = daytona.get(sandbox_id)
# Delete the sandbox
daytona.remove(sandbox)

View File

@ -162,7 +162,7 @@ async def archive_sandbox(project: Dict[str, Any], dry_run: bool) -> bool:
return True
# Get the sandbox
sandbox = daytona.get_current_sandbox(sandbox_id)
sandbox = daytona.get(sandbox_id)
# Check sandbox state - it must be stopped before archiving
sandbox_info = sandbox.info()

View File

@ -170,7 +170,7 @@ async def archive_sandbox(project: Dict[str, Any], dry_run: bool) -> bool:
return True
# Get the sandbox
sandbox = daytona.get_current_sandbox(sandbox_id)
sandbox = daytona.get(sandbox_id)
# Check sandbox state - it must be stopped before archiving
sandbox_info = sandbox.info()

View File

@ -83,7 +83,7 @@ async def delete_sandboxes(projects: List[Dict[str, Any]]) -> None:
logger.info(f"Deleting sandbox {sandbox_id} for project '{project_name}' (ID: {project_id})")
# Get the sandbox and delete it
sandbox = daytona.get_current_sandbox(sandbox_id)
sandbox = daytona.get(sandbox_id)
daytona.delete(sandbox)
logger.info(f"Successfully deleted sandbox {sandbox_id}")