prediction-market-agent-tooling 0.64.5__py3-none-any.whl → 0.64.6.dev618__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.
@@ -28,6 +28,8 @@ from prediction_market_agent_tooling.tools.datetime_utc import DatetimeUTC
28
28
  from prediction_market_agent_tooling.tools.db.db_manager import DBManager
29
29
  from prediction_market_agent_tooling.tools.utils import utcnow
30
30
 
31
+ DB_CACHE_LOG_PREFIX = "[db-cache]"
32
+
31
33
  FunctionT = TypeVar("FunctionT", bound=Callable[..., Any])
32
34
 
33
35
 
@@ -54,8 +56,7 @@ def db_cache(
54
56
  ignore_args: Sequence[str] | None = None,
55
57
  ignore_arg_types: Sequence[type] | None = None,
56
58
  log_error_on_unsavable_data: bool = True,
57
- ) -> Callable[[FunctionT], FunctionT]:
58
- ...
59
+ ) -> Callable[[FunctionT], FunctionT]: ...
59
60
 
60
61
 
61
62
  @overload
@@ -68,8 +69,7 @@ def db_cache(
68
69
  ignore_args: Sequence[str] | None = None,
69
70
  ignore_arg_types: Sequence[type] | None = None,
70
71
  log_error_on_unsavable_data: bool = True,
71
- ) -> FunctionT:
72
- ...
72
+ ) -> FunctionT: ...
73
73
 
74
74
 
75
75
  def db_cache(
@@ -173,7 +173,7 @@ def db_cache(
173
173
  if cached_result:
174
174
  logger.info(
175
175
  # Keep the special [case-hit] identifier so we can easily track it in GCP.
176
- f"[cache-hit] Cache hit for {full_function_name} with args {args_dict} and output {cached_result.result}"
176
+ f"{DB_CACHE_LOG_PREFIX} [cache-hit] Cache hit for {full_function_name} with args {args_dict} and output {cached_result.result}"
177
177
  )
178
178
  if is_pydantic_model:
179
179
  # If the output contains any Pydantic models, we need to initialise them.
@@ -184,7 +184,7 @@ def db_cache(
184
184
  except ValueError as e:
185
185
  # In case of backward-incompatible pydantic model, just treat it as cache miss, to not error out.
186
186
  logger.warning(
187
- f"Can not validate {cached_result=} into {return_type=} because {e=}, treating as cache miss."
187
+ f"{DB_CACHE_LOG_PREFIX} [cache-miss] Can not validate {cached_result=} into {return_type=} because {e=}, treating as cache miss."
188
188
  )
189
189
  cached_result = None
190
190
  else:
@@ -194,7 +194,7 @@ def db_cache(
194
194
  computed_result = func(*args, **kwargs)
195
195
  # Keep the special [case-miss] identifier so we can easily track it in GCP.
196
196
  logger.info(
197
- f"[cache-miss] Cache miss for {full_function_name} with args {args_dict}, computed the output {computed_result}"
197
+ f"{DB_CACHE_LOG_PREFIX} [cache-miss] Cache miss for {full_function_name} with args {args_dict}, computed the output {computed_result}"
198
198
  )
199
199
 
200
200
  # If postgres access was specified, save it.
@@ -212,16 +212,18 @@ def db_cache(
212
212
  with DBManager(
213
213
  api_keys.sqlalchemy_db_url.get_secret_value()
214
214
  ).get_session() as session:
215
- logger.info(f"Saving {cache_entry} into database.")
215
+ logger.info(
216
+ f"{DB_CACHE_LOG_PREFIX} [cache-info] Saving {cache_entry} into database."
217
+ )
216
218
  session.add(cache_entry)
217
219
  session.commit()
218
220
  except (DataError, psycopg2.errors.UntranslatableCharacter) as e:
219
221
  (logger.error if log_error_on_unsavable_data else logger.warning)(
220
- f"Failed to save {cache_entry} into database, ignoring, because: {e}"
222
+ f"{DB_CACHE_LOG_PREFIX} [cache-error] Failed to save {cache_entry} into database, ignoring, because: {e}"
221
223
  )
222
224
  except Exception:
223
225
  logger.exception(
224
- f"Failed to save {cache_entry} into database, ignoring."
226
+ f"{DB_CACHE_LOG_PREFIX} [cache-error] Failed to save {cache_entry} into database, ignoring."
225
227
  )
226
228
 
227
229
  return computed_result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.64.5
3
+ Version: 0.64.6.dev618
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -86,7 +86,7 @@ prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256
86
86
  prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
87
87
  prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py,sha256=THMXwFlskvzbjnX_OiYtDSzI8XVFyULWfP2525_9UGc,429
88
88
  prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=68zFWUj43GUaSpOPowVrbI-t6qbCE29RsVHNzCVuJ9U,175
89
- prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=e7CLFPTlxYFx0pM3x5sWyn_g9pIigPSvrP0mMmiOhUg,11859
89
+ prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=dkjBvRUakWXCkUM1nXxXk62ZPpaESyFMtwRovj4HGRI,12119
90
90
  prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
91
91
  prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
92
92
  prediction_market_agent_tooling/tools/contract.py,sha256=Yex8MVYvdBTMZLESLqKpwEyT8EGAfkJRri5kCaPqrBM,21235
@@ -124,8 +124,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=yuW8iPPtcpP4eLH2nORMD
124
124
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
125
125
  prediction_market_agent_tooling/tools/utils.py,sha256=AC2a68jwASMWuQi-w8twl8b_M52YwrEJ81abmuEaqMY,6661
126
126
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=zRq-eeBGWt8uUGN9G_WfjmJ0eVvO8aWE9S0Pz_Y6AOA,12342
127
- prediction_market_agent_tooling-0.64.5.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
128
- prediction_market_agent_tooling-0.64.5.dist-info/METADATA,sha256=EPfSPw78Gf7zr3qLdKFha7YltbMwA-EvW4PkI8lykMU,8741
129
- prediction_market_agent_tooling-0.64.5.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
130
- prediction_market_agent_tooling-0.64.5.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
131
- prediction_market_agent_tooling-0.64.5.dist-info/RECORD,,
127
+ prediction_market_agent_tooling-0.64.6.dev618.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
128
+ prediction_market_agent_tooling-0.64.6.dev618.dist-info/METADATA,sha256=M_UHw2KLlPUDnPIoCe-R5aDQoqd-W3F9oVgO-SzA318,8748
129
+ prediction_market_agent_tooling-0.64.6.dev618.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
130
+ prediction_market_agent_tooling-0.64.6.dev618.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
131
+ prediction_market_agent_tooling-0.64.6.dev618.dist-info/RECORD,,