prediction-market-agent-tooling 0.56.1__py3-none-any.whl → 0.56.2.dev129__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prediction_market_agent_tooling/config.py +1 -1
- prediction_market_agent_tooling/tools/caches/db_cache.py +17 -13
- {prediction_market_agent_tooling-0.56.1.dist-info → prediction_market_agent_tooling-0.56.2.dev129.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.56.1.dist-info → prediction_market_agent_tooling-0.56.2.dev129.dist-info}/RECORD +7 -7
- {prediction_market_agent_tooling-0.56.1.dist-info → prediction_market_agent_tooling-0.56.2.dev129.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.56.1.dist-info → prediction_market_agent_tooling-0.56.2.dev129.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.56.1.dist-info → prediction_market_agent_tooling-0.56.2.dev129.dist-info}/entry_points.txt +0 -0
@@ -15,7 +15,7 @@ from typing import (
|
|
15
15
|
)
|
16
16
|
|
17
17
|
from pydantic import BaseModel
|
18
|
-
from sqlalchemy import Column
|
18
|
+
from sqlalchemy import Column, Engine
|
19
19
|
from sqlalchemy.dialects.postgresql import JSONB
|
20
20
|
from sqlmodel import Field, Session, SQLModel, create_engine, desc, select
|
21
21
|
|
@@ -40,6 +40,9 @@ class FunctionCache(SQLModel, table=True):
|
|
40
40
|
created_at: DatetimeUTC = Field(default_factory=utcnow, index=True)
|
41
41
|
|
42
42
|
|
43
|
+
DB_CACHE_ENGINE: None | Engine = None
|
44
|
+
|
45
|
+
|
43
46
|
@overload
|
44
47
|
def db_cache(
|
45
48
|
func: None = None,
|
@@ -97,15 +100,16 @@ def db_cache(
|
|
97
100
|
if not api_keys.ENABLE_CACHE:
|
98
101
|
return func(*args, **kwargs)
|
99
102
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
global DB_CACHE_ENGINE
|
104
|
+
if DB_CACHE_ENGINE is None:
|
105
|
+
DB_CACHE_ENGINE = create_engine(
|
106
|
+
api_keys.sqlalchemy_db_url.get_secret_value(),
|
107
|
+
# Use custom json serializer and deserializer, because otherwise, for example `datetime` serialization would fail.
|
108
|
+
json_serializer=json_serializer,
|
109
|
+
json_deserializer=json_deserializer,
|
110
|
+
)
|
111
|
+
# Create table if it doesn't exist
|
112
|
+
SQLModel.metadata.create_all(DB_CACHE_ENGINE)
|
109
113
|
|
110
114
|
# Convert *args and **kwargs to a single dictionary, where we have names for arguments passed as args as well.
|
111
115
|
signature = inspect.signature(func)
|
@@ -151,7 +155,7 @@ def db_cache(
|
|
151
155
|
if return_type is not None and contains_pydantic_model(return_type):
|
152
156
|
is_pydantic_model = True
|
153
157
|
|
154
|
-
with Session(
|
158
|
+
with Session(DB_CACHE_ENGINE) as session:
|
155
159
|
# Try to get cached result
|
156
160
|
statement = (
|
157
161
|
select(FunctionCache)
|
@@ -195,7 +199,7 @@ def db_cache(
|
|
195
199
|
)
|
196
200
|
|
197
201
|
# If postgres access was specified, save it.
|
198
|
-
if
|
202
|
+
if cache_none or computed_result is not None:
|
199
203
|
cache_entry = FunctionCache(
|
200
204
|
function_name=function_name,
|
201
205
|
full_function_name=full_function_name,
|
@@ -204,7 +208,7 @@ def db_cache(
|
|
204
208
|
result=computed_result,
|
205
209
|
created_at=utcnow(),
|
206
210
|
)
|
207
|
-
with Session(
|
211
|
+
with Session(DB_CACHE_ENGINE) as session:
|
208
212
|
logger.info(f"Saving {cache_entry} into database.")
|
209
213
|
session.add(cache_entry)
|
210
214
|
session.commit()
|
@@ -16,7 +16,7 @@ prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-
|
|
16
16
|
prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-CcAFJg1m9Y_XuaeIHPB29QR8,3971
|
17
17
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=MqTiaaJ3cYiOLUVR7OyImLWxcEya3Rl5JyFYW-K0lwM,17097
|
18
18
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=D0MfUkVZllmvcU0VOurk9tcKT7JTtwwOp-63zuCBVuc,2880
|
19
|
-
prediction_market_agent_tooling/config.py,sha256=
|
19
|
+
prediction_market_agent_tooling/config.py,sha256=6iB8A4byexiemUajIw2SzRDQ8E8w0catyg7aH_mHpsY,6732
|
20
20
|
prediction_market_agent_tooling/deploy/agent.py,sha256=dpc94DUo8Gq1LdRdw6k78vm_47OeJIfomG9CRVpgzk0,22757
|
21
21
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
|
22
22
|
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=kMrIE3wMv_IB6nJd_1DmDXDkEZhsXFOgyTd7JZ0gqHI,13068
|
@@ -71,7 +71,7 @@ prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256
|
|
71
71
|
prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
|
72
72
|
prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py,sha256=THMXwFlskvzbjnX_OiYtDSzI8XVFyULWfP2525_9UGc,429
|
73
73
|
prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=kpIb-ci67Vc1Yqqaa-_S4OUkbhWSIYog4_Iwp69HU_k,97
|
74
|
-
prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=
|
74
|
+
prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=s8MKNWa3EFIRMZbi5YqgOd4S1boMPkUrGFgtW8qBNlw,12844
|
75
75
|
prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=tGHHd9HCiE_hCCtPtloHZQdDfBuiow9YsqJNYi2Tx_0,499
|
76
76
|
prediction_market_agent_tooling/tools/contract.py,sha256=s3yo8IbXTcvAJcPfLM0_NbgaEsWwLsPmyVnOgyjq_xI,20919
|
77
77
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
@@ -99,8 +99,8 @@ prediction_market_agent_tooling/tools/tavily/tavily_models.py,sha256=5ldQs1pZe6u
|
|
99
99
|
prediction_market_agent_tooling/tools/tavily/tavily_search.py,sha256=Kw2mXNkMTYTEe1MBSTqhQmLoeXtgb6CkmHlcAJvhtqE,3809
|
100
100
|
prediction_market_agent_tooling/tools/utils.py,sha256=1VvunbTmzGzpIlRukFhArreFNxJPbsg4lLtQNk0r2bY,7185
|
101
101
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=44W8siSLNQxeib98bbwAe7V5C609NHNlUuxwuWIRDiY,11838
|
102
|
-
prediction_market_agent_tooling-0.56.
|
103
|
-
prediction_market_agent_tooling-0.56.
|
104
|
-
prediction_market_agent_tooling-0.56.
|
105
|
-
prediction_market_agent_tooling-0.56.
|
106
|
-
prediction_market_agent_tooling-0.56.
|
102
|
+
prediction_market_agent_tooling-0.56.2.dev129.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
103
|
+
prediction_market_agent_tooling-0.56.2.dev129.dist-info/METADATA,sha256=uWLV8rw76xcE9yFjv1CYRp3mpM_HbYBFho1qpIyeoCc,8113
|
104
|
+
prediction_market_agent_tooling-0.56.2.dev129.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
105
|
+
prediction_market_agent_tooling-0.56.2.dev129.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
106
|
+
prediction_market_agent_tooling-0.56.2.dev129.dist-info/RECORD,,
|
File without changes
|
File without changes
|