prediction-market-agent-tooling 0.57.6__py3-none-any.whl → 0.57.7__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/tools/caches/db_cache.py +9 -3
- prediction_market_agent_tooling/tools/db/db_manager.py +10 -9
- prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +3 -1
- {prediction_market_agent_tooling-0.57.6.dist-info → prediction_market_agent_tooling-0.57.7.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.57.6.dist-info → prediction_market_agent_tooling-0.57.7.dist-info}/RECORD +8 -8
- {prediction_market_agent_tooling-0.57.6.dist-info → prediction_market_agent_tooling-0.57.7.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.57.6.dist-info → prediction_market_agent_tooling-0.57.7.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.57.6.dist-info → prediction_market_agent_tooling-0.57.7.dist-info}/entry_points.txt +0 -0
@@ -98,7 +98,9 @@ def db_cache(
|
|
98
98
|
if not api_keys.ENABLE_CACHE:
|
99
99
|
return func(*args, **kwargs)
|
100
100
|
|
101
|
-
DBManager(api_keys).create_tables(
|
101
|
+
DBManager(api_keys.sqlalchemy_db_url.get_secret_value()).create_tables(
|
102
|
+
[FunctionCache]
|
103
|
+
)
|
102
104
|
|
103
105
|
# Convert *args and **kwargs to a single dictionary, where we have names for arguments passed as args as well.
|
104
106
|
signature = inspect.signature(func)
|
@@ -143,7 +145,9 @@ def db_cache(
|
|
143
145
|
return_type
|
144
146
|
)
|
145
147
|
|
146
|
-
with DBManager(
|
148
|
+
with DBManager(
|
149
|
+
api_keys.sqlalchemy_db_url.get_secret_value()
|
150
|
+
).get_session() as session:
|
147
151
|
# Try to get cached result
|
148
152
|
statement = (
|
149
153
|
select(FunctionCache)
|
@@ -196,7 +200,9 @@ def db_cache(
|
|
196
200
|
result=computed_result,
|
197
201
|
created_at=utcnow(),
|
198
202
|
)
|
199
|
-
with DBManager(
|
203
|
+
with DBManager(
|
204
|
+
api_keys.sqlalchemy_db_url.get_secret_value()
|
205
|
+
).get_session() as session:
|
200
206
|
logger.info(f"Saving {cache_entry} into database.")
|
201
207
|
session.add(cache_entry)
|
202
208
|
session.commit()
|
@@ -15,24 +15,26 @@ from prediction_market_agent_tooling.tools.caches.serializers import (
|
|
15
15
|
class DBManager:
|
16
16
|
_instances: dict[str, "DBManager"] = {}
|
17
17
|
|
18
|
-
def __new__(cls,
|
19
|
-
sqlalchemy_db_url
|
18
|
+
def __new__(cls, sqlalchemy_db_url: str | None = None) -> "DBManager":
|
19
|
+
if sqlalchemy_db_url is None:
|
20
|
+
sqlalchemy_db_url = APIKeys().sqlalchemy_db_url.get_secret_value()
|
21
|
+
|
20
22
|
# Hash the secret value to not store secrets in plain text.
|
21
|
-
url_hash = hashlib.md5(
|
22
|
-
sqlalchemy_db_url.get_secret_value().encode()
|
23
|
-
).hexdigest()
|
23
|
+
url_hash = hashlib.md5(sqlalchemy_db_url.encode()).hexdigest()
|
24
24
|
# Return singleton per database connection.
|
25
25
|
if url_hash not in cls._instances:
|
26
26
|
instance = super(DBManager, cls).__new__(cls)
|
27
27
|
cls._instances[url_hash] = instance
|
28
28
|
return cls._instances[url_hash]
|
29
29
|
|
30
|
-
def __init__(self,
|
30
|
+
def __init__(self, sqlalchemy_db_url: str | None = None) -> None:
|
31
31
|
if hasattr(self, "_initialized"):
|
32
32
|
return
|
33
|
-
sqlalchemy_db_url = (
|
33
|
+
sqlalchemy_db_url = (
|
34
|
+
sqlalchemy_db_url or APIKeys().sqlalchemy_db_url.get_secret_value()
|
35
|
+
)
|
34
36
|
self._engine = create_engine(
|
35
|
-
sqlalchemy_db_url
|
37
|
+
sqlalchemy_db_url,
|
36
38
|
json_serializer=json_serializer,
|
37
39
|
json_deserializer=json_deserializer,
|
38
40
|
pool_size=2,
|
@@ -53,7 +55,6 @@ class DBManager:
|
|
53
55
|
def create_tables(
|
54
56
|
self, sqlmodel_tables: Sequence[type[SQLModel]] | None = None
|
55
57
|
) -> None:
|
56
|
-
# Determine tables to create
|
57
58
|
if sqlmodel_tables is not None:
|
58
59
|
tables_to_create = []
|
59
60
|
for sqlmodel_table in sqlmodel_tables:
|
@@ -25,7 +25,9 @@ class RelevantNewsCacheModel(SQLModel, table=True):
|
|
25
25
|
|
26
26
|
class RelevantNewsResponseCache:
|
27
27
|
def __init__(self, api_keys: APIKeys | None = None):
|
28
|
-
self.db_manager = DBManager(
|
28
|
+
self.db_manager = DBManager(
|
29
|
+
(api_keys or APIKeys()).sqlalchemy_db_url.get_secret_value()
|
30
|
+
)
|
29
31
|
self._initialize_db()
|
30
32
|
|
31
33
|
def _initialize_db(self) -> None:
|
@@ -73,14 +73,14 @@ prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256
|
|
73
73
|
prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
|
74
74
|
prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py,sha256=THMXwFlskvzbjnX_OiYtDSzI8XVFyULWfP2525_9UGc,429
|
75
75
|
prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=kpIb-ci67Vc1Yqqaa-_S4OUkbhWSIYog4_Iwp69HU_k,97
|
76
|
-
prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=
|
76
|
+
prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=aafau_n_AUbLIwkyIRiTPgKB0dmM0767mSqyPDLF2A4,10576
|
77
77
|
prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
|
78
78
|
prediction_market_agent_tooling/tools/caches/serializers.py,sha256=upSXN5__rmRlzJ6tv1h7FodKzJu9eCkFrN_zeuwroJM,2151
|
79
79
|
prediction_market_agent_tooling/tools/contract.py,sha256=tJHwbDXRRRS7g-vIzqfYTOPQBcU5lqb9o_FF9OECZQ8,22941
|
80
80
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
81
81
|
prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
|
82
82
|
prediction_market_agent_tooling/tools/datetime_utc.py,sha256=2JSWF7AXQnv04_D_cu9Vmdkq0TWmGJ1QcK9AeqrA-U8,2765
|
83
|
-
prediction_market_agent_tooling/tools/db/db_manager.py,sha256=
|
83
|
+
prediction_market_agent_tooling/tools/db/db_manager.py,sha256=GtzHH1NLl8HwqC8Z7s6eTlIQXuV0blxfaV2PeQrBnfQ,3013
|
84
84
|
prediction_market_agent_tooling/tools/google_utils.py,sha256=t3_UEEvKX3L0biSIQ560GdRbllQ6eprhK_upE243A-0,3185
|
85
85
|
prediction_market_agent_tooling/tools/hexbytes_custom.py,sha256=Bp94qgPjvjWf1Vb4lNzGFDXRdThw1rJ91vL6r2PWq5E,2096
|
86
86
|
prediction_market_agent_tooling/tools/httpx_cached_client.py,sha256=RxD-hwtZCMctnMwfzy8t51W9Z9gxFGtDYxBIMChazpc,406
|
@@ -95,7 +95,7 @@ prediction_market_agent_tooling/tools/omen/reality_accuracy.py,sha256=M1SF7iSW1g
|
|
95
95
|
prediction_market_agent_tooling/tools/parallelism.py,sha256=6Gou0hbjtMZrYvxjTDFUDZuxmE2nqZVbb6hkg1hF82A,1022
|
96
96
|
prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py,sha256=95l84aztFaxcRLLcRQ46yKJbIlOEuDAbIGLouyliDzA,1316
|
97
97
|
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py,sha256=CddJem7tk15NAudJDwmuL8znTycbR-YI8kTNtd3LzG8,5474
|
98
|
-
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py,sha256=
|
98
|
+
prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py,sha256=kNWq92T11Knb9mYBZlMiZUzOpKgCd-5adanylQUMRJA,3085
|
99
99
|
prediction_market_agent_tooling/tools/safe.py,sha256=9vxGGLvSPnfy-sxUFDpBTe8omqpGXP7MzvGPp6bRxrU,5197
|
100
100
|
prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
|
101
101
|
prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
|
@@ -104,8 +104,8 @@ prediction_market_agent_tooling/tools/tavily/tavily_search.py,sha256=Kw2mXNkMTYT
|
|
104
104
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
105
105
|
prediction_market_agent_tooling/tools/utils.py,sha256=WvuUCHgMCiMq8_wMm5PHNwvLhcdDk2zGKaAM8OUC-qY,6438
|
106
106
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=wqUDCed3iNrn1Wao1iwGN6tzIrhpzrTRj319wlveJEo,12275
|
107
|
-
prediction_market_agent_tooling-0.57.
|
108
|
-
prediction_market_agent_tooling-0.57.
|
109
|
-
prediction_market_agent_tooling-0.57.
|
110
|
-
prediction_market_agent_tooling-0.57.
|
111
|
-
prediction_market_agent_tooling-0.57.
|
107
|
+
prediction_market_agent_tooling-0.57.7.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
108
|
+
prediction_market_agent_tooling-0.57.7.dist-info/METADATA,sha256=dDVW3NpNlZdOWksAXIUHFFynWSvxbA_kZXffQ-Af1Ys,8188
|
109
|
+
prediction_market_agent_tooling-0.57.7.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
110
|
+
prediction_market_agent_tooling-0.57.7.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
111
|
+
prediction_market_agent_tooling-0.57.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|