diff --git a/prediction_market_agent_tooling/config.py b/prediction_market_agent_tooling/config.py index 9a9efdd6..6330dce3 100644 --- a/prediction_market_agent_tooling/config.py +++ b/prediction_market_agent_tooling/config.py @@ -53,7 +53,7 @@ class APIKeys(BaseSettings): SQLALCHEMY_DB_URL: t.Optional[SecretStr] = None - ENABLE_CACHE: bool = True + ENABLE_CACHE: bool = False CACHE_DIR: str = "./.cache" @property diff --git a/prediction_market_agent_tooling/tools/caches/db_cache.py b/prediction_market_agent_tooling/tools/caches/db_cache.py index 500b686c..4da6ffb8 100644 --- a/prediction_market_agent_tooling/tools/caches/db_cache.py +++ b/prediction_market_agent_tooling/tools/caches/db_cache.py @@ -102,6 +102,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any: # Use custom json serializer and deserializer, because otherwise, for example `datetime` serialization would fail. json_serializer=json_serializer, json_deserializer=json_deserializer, + pool_size=1, ) # Create table if it doesn't exist @@ -195,7 +196,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any: ) # If postgres access was specified, save it. - if engine is not None and (cache_none or computed_result is not None): + if cache_none or computed_result is not None: cache_entry = FunctionCache( function_name=function_name, full_function_name=full_function_name, @@ -209,6 +210,7 @@ def wrapper(*args: Any, **kwargs: Any) -> Any: session.add(cache_entry) session.commit() + engine.dispose() return computed_result return cast(FunctionT, wrapper) diff --git a/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py b/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py index d1257ec5..8fc280cc 100644 --- a/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +++ b/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py @@ -25,9 +25,12 @@ class RelevantNewsCacheModel(SQLModel, table=True): class RelevantNewsResponseCache: def __init__(self, sqlalchemy_db_url: str | None = None): self.engine = create_engine( - sqlalchemy_db_url - if sqlalchemy_db_url - else APIKeys().sqlalchemy_db_url.get_secret_value() + ( + sqlalchemy_db_url + if sqlalchemy_db_url + else APIKeys().sqlalchemy_db_url.get_secret_value() + ), + pool_size=1, ) self._initialize_db() diff --git a/pyproject.toml b/pyproject.toml index 83197c3a..e608b8c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "prediction-market-agent-tooling" -version = "0.56.1" +version = "0.56.2" description = "Tools to benchmark, deploy and monitor prediction market agents." authors = ["Gnosis"] readme = "README.md"