Skip to content

Commit

Permalink
🔄 synced local 'skyvern/' with remote 'skyvern/'
Browse files Browse the repository at this point in the history
<!-- ELLIPSIS_HIDDEN -->

> [!IMPORTANT]
> Introduce database statement timeout configuration in `config.py` and apply it in `client.py` for database connections.
>
>   - **Configuration**:
>     - Add `DATABASE_STATEMENT_TIMEOUT_MS` in `config.py` with default 60000 ms.
>   - **Database Client**:
>     - Update `DB_CONNECT_ARGS` in `client.py` to include `statement_timeout` using `DATABASE_STATEMENT_TIMEOUT_MS`.
>     - Modify `create_async_engine` in `AgentDB` to use `DB_CONNECT_ARGS`.
>
> <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=Skyvern-AI%2Fskyvern-cloud&utm_source=github&utm_medium=referral)<sup> for 0c2fddc79961a2f547c354c978f30f7882ff9641. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->
  • Loading branch information
wintonzheng committed Nov 20, 2024
1 parent 9896a70 commit 942020f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions skyvern/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Settings(BaseSettings):
MAX_RETRIES_PER_STEP: int = 5
DEBUG_MODE: bool = False
DATABASE_STRING: str = "postgresql+psycopg://skyvern@localhost/skyvern"
DATABASE_STATEMENT_TIMEOUT_MS: int = 60000
PROMPT_ACTION_HISTORY_WINDOW: int = 1
TASK_RESPONSE_ACTION_SCREENSHOT_COUNT: int = 3

Expand Down
12 changes: 11 additions & 1 deletion skyvern/forge/sdk/db/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,22 @@

LOG = structlog.get_logger()

DB_CONNECT_ARGS: dict[str, Any] = {
"options": f"-c statement_timeout={settings.DATABASE_STATEMENT_TIMEOUT_MS}",
}
if "postgresql+asyncpg" in settings.DATABASE_STRING:
DB_CONNECT_ARGS = {"server_settings": {"statement_timeout": str(settings.DATABASE_STATEMENT_TIMEOUT_MS)}}


class AgentDB:
def __init__(self, database_string: str, debug_enabled: bool = False) -> None:
super().__init__()
self.debug_enabled = debug_enabled
self.engine = create_async_engine(database_string, json_serializer=_custom_json_serializer, pool_pre_ping=True)
self.engine = create_async_engine(
database_string,
json_serializer=_custom_json_serializer,
connect_args=DB_CONNECT_ARGS,
)
self.Session = async_sessionmaker(bind=self.engine)

async def create_task(
Expand Down

0 comments on commit 942020f

Please sign in to comment.