prediction-market-agent-tooling 0.48.15__py3-none-any.whl → 0.48.17__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.
@@ -36,8 +36,8 @@ class JobAgentMarket(AgentMarket, ABC):
36
36
  def get_reward(self, max_bond: float) -> float:
37
37
  """Reward for completing this job."""
38
38
 
39
- @abstractmethod
40
39
  @classmethod
40
+ @abstractmethod
41
41
  def get_jobs(
42
42
  cls, limit: int | None, filter_by: FilterBy, sort_by: SortBy
43
43
  ) -> t.Sequence["JobAgentMarket"]:
@@ -49,6 +49,11 @@ def patch_logger() -> None:
49
49
  Function to patch loggers according to the deployed environment.
50
50
  Patches Loguru's logger, Python's default logger, warnings library and also monkey-patch print function as many libraries just use it.
51
51
  """
52
+ if not getattr(logger, "_patched", False):
53
+ logger._patched = True # type: ignore[attr-defined] # Hacky way to store a flag on the logger object, to not patch it multiple times.
54
+ else:
55
+ return
56
+
52
57
  config = LogConfig()
53
58
 
54
59
  if config.LOG_FORMAT == LogFormat.GCP:
@@ -116,6 +121,4 @@ def simple_warning_format(message, category, filename, lineno, line=None): # ty
116
121
  ) # Escape new lines, because otherwise logs will be broken.
117
122
 
118
123
 
119
- if not getattr(logger, "_patched", False):
120
- patch_logger()
121
- logger._patched = True # type: ignore[attr-defined] # Hacky way to store a flag on the logger object, to not patch it multiple times.
124
+ patch_logger()
@@ -150,10 +150,5 @@ def get_trace_for_bet(
150
150
  add_utc_timezone_validator(bet.created_time),
151
151
  [t.timestamp for t in traces_for_bet],
152
152
  )
153
- # Sanity check - the trace should be after the bet
154
- if traces_for_bet[closest_trace_index].timestamp < add_utc_timezone_validator(
155
- bet.created_time
156
- ):
157
- return None
158
153
 
159
154
  return traces_for_bet[closest_trace_index]
@@ -1,12 +1,8 @@
1
- import concurrent
2
- from concurrent.futures import Executor
3
- from concurrent.futures.process import ProcessPoolExecutor
4
- from concurrent.futures.thread import ThreadPoolExecutor
5
1
  from typing import Callable, Generator, TypeVar
6
2
 
7
- # Max workers to 5 to avoid rate limiting on some APIs, create a custom executor if you need more workers.
8
- DEFAULT_THREADPOOL_EXECUTOR = ThreadPoolExecutor(max_workers=5)
9
- DEFAULT_PROCESSPOOL_EXECUTOR = ProcessPoolExecutor(max_workers=5)
3
+ from loky import get_reusable_executor
4
+
5
+ from prediction_market_agent_tooling.loggers import patch_logger
10
6
 
11
7
  A = TypeVar("A")
12
8
  B = TypeVar("B")
@@ -15,14 +11,11 @@ B = TypeVar("B")
15
11
  def par_map(
16
12
  items: list[A],
17
13
  func: Callable[[A], B],
18
- executor: Executor = DEFAULT_THREADPOOL_EXECUTOR,
14
+ max_workers: int = 5,
19
15
  ) -> "list[B]":
20
- """Applies the function to each element using the specified executor. Awaits for all results.
21
- If executor is ProcessPoolExecutor, make sure the function passed is pickable, e.g. no lambda functions
22
- """
23
- futures: list[concurrent.futures._base.Future[B]] = [
24
- executor.submit(func, item) for item in items
25
- ]
16
+ """Applies the function to each element using the specified executor. Awaits for all results."""
17
+ executor = get_reusable_executor(max_workers=max_workers, initializer=patch_logger)
18
+ futures = [executor.submit(func, item) for item in items]
26
19
  results = []
27
20
  for fut in futures:
28
21
  results.append(fut.result())
@@ -32,13 +25,9 @@ def par_map(
32
25
  def par_generator(
33
26
  items: list[A],
34
27
  func: Callable[[A], B],
35
- executor: Executor = DEFAULT_THREADPOOL_EXECUTOR,
28
+ max_workers: int = 5,
36
29
  ) -> Generator[B, None, None]:
37
- """Applies the function to each element using the specified executor. Yields results as they come.
38
- If executor is ProcessPoolExecutor, make sure the function passed is pickable, e.g. no lambda functions.
39
- """
40
- futures: list[concurrent.futures._base.Future[B]] = [
41
- executor.submit(func, item) for item in items
42
- ]
43
- for fut in concurrent.futures.as_completed(futures):
44
- yield fut.result()
30
+ """Applies the function to each element using the specified executor. Yields results as they come."""
31
+ executor = get_reusable_executor(max_workers=max_workers, initializer=patch_logger)
32
+ for res in executor.map(func, items):
33
+ yield res
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.48.15
3
+ Version: 0.48.17
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.12
@@ -26,6 +26,7 @@ Requires-Dist: langchain-community (>=0.0.19)
26
26
  Requires-Dist: langchain-openai (>=0.1.0,<0.2.0) ; extra == "langchain"
27
27
  Requires-Dist: langfuse (>=2.42.0,<3.0.0)
28
28
  Requires-Dist: loguru (>=0.7.2,<0.8.0)
29
+ Requires-Dist: loky (>=3.4.1,<4.0.0)
29
30
  Requires-Dist: numpy (>=1.26.4,<2.0.0)
30
31
  Requires-Dist: openai (>=1.0.0,<2.0.0) ; extra == "openai"
31
32
  Requires-Dist: prompt-toolkit (>=3.0.43,<4.0.0)
@@ -25,9 +25,9 @@ prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=oyW0jgrUT2Tr49c7GlpcM
25
25
  prediction_market_agent_tooling/gtypes.py,sha256=O77co9-GWmHJo_NyBzRVkli5L1xqweI28JmsyaAHUHs,2474
26
26
  prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  prediction_market_agent_tooling/jobs/jobs.py,sha256=I07yh0GJ-xhlvQaOUQB8xlSnihhcbU2c7DZ4ZND14c0,1246
28
- prediction_market_agent_tooling/jobs/jobs_models.py,sha256=wlBhh-D8pUegBCTpzTfla6crGlNMSqqNX7yDqMcRLYI,1326
28
+ prediction_market_agent_tooling/jobs/jobs_models.py,sha256=8JS9n_EVgmNzqRg1YUjopPVZRjqFneVYCKnX4UEFy3I,1326
29
29
  prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=EAzo63vhSt1P7ddoDubdmvgzFf-ieQRTDCRLzYkH3js,3922
30
- prediction_market_agent_tooling/loggers.py,sha256=JiBTgvb34O9dKHYKZyQ0UzojPUy6KSFQSTfbBIXopSY,3721
30
+ prediction_market_agent_tooling/loggers.py,sha256=Am6HHXRNO545BO3l7Ue9Wb2TkYE1OK8KKhGbI3XypVU,3751
31
31
  prediction_market_agent_tooling/markets/agent_market.py,sha256=nVJO1MY7_l-YP1Q7-mGLtRgIHK8M-yt3Ht1yyQPwImM,10176
32
32
  prediction_market_agent_tooling/markets/categorize.py,sha256=jsoHWvZk9pU6n17oWSCcCxNNYVwlb_NXsZxKRI7vmsk,1301
33
33
  prediction_market_agent_tooling/markets/data_models.py,sha256=vaJ049j2Anf5sZWjNflsCEag-Y0G1mTu6bCWT74HxqM,3266
@@ -75,8 +75,8 @@ prediction_market_agent_tooling/tools/image_gen/image_gen.py,sha256=HzRwBx62hOXB
75
75
  prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py,sha256=8A3U2uxsCsOfLjru-6R_PPIAuiKY4qFkWp_GSBPV6-s,1280
76
76
  prediction_market_agent_tooling/tools/is_predictable.py,sha256=QapzvJVgUZdhucgmxhzWAQ885BwSwvYUi0SG8mkLQMQ,6738
77
77
  prediction_market_agent_tooling/tools/langfuse_.py,sha256=jI_4ROxqo41CCnWGS1vN_AeDVhRzLMaQLxH3kxDu3L8,1153
78
- prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=EljGXIal3xApSzi5oaNJl4pRm66nayBWEpXR68SuVy0,4951
79
- prediction_market_agent_tooling/tools/parallelism.py,sha256=Rz8QdVUWX8KCbr8UZfaC_b1GBWIb3bXwITUumuvBJ60,1633
78
+ prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=HZ8PN__CahMeNLaEx4v9esOqow6XEeezuYOOZD9-Ol8,4741
79
+ prediction_market_agent_tooling/tools/parallelism.py,sha256=6Gou0hbjtMZrYvxjTDFUDZuxmE2nqZVbb6hkg1hF82A,1022
80
80
  prediction_market_agent_tooling/tools/safe.py,sha256=h0xOO0eNtitClf0fPkn-0oTc6A_bflDTee98V_aiV-A,5195
81
81
  prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
82
82
  prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
@@ -84,8 +84,8 @@ prediction_market_agent_tooling/tools/tavily_storage/tavily_models.py,sha256=Uq2
84
84
  prediction_market_agent_tooling/tools/tavily_storage/tavily_storage.py,sha256=xrtQH9v5pXycBRyc5j45pWqkSffkoc9efNIU1_G633Q,3706
85
85
  prediction_market_agent_tooling/tools/utils.py,sha256=JE9YWtPPhnTgLiOyGAZDNG5K8nCwUY9IZEuAlm9UcxA,6611
86
86
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=IZDxHhUJH5RsaRkK9DW6z1RYdk2cz5RqLMZG3T6Gv1U,11602
87
- prediction_market_agent_tooling-0.48.15.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
88
- prediction_market_agent_tooling-0.48.15.dist-info/METADATA,sha256=vp4AH8yoRuOMnzAizjbHTWMTVxKWnvRLNrJxLt-Utm0,7811
89
- prediction_market_agent_tooling-0.48.15.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
90
- prediction_market_agent_tooling-0.48.15.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
91
- prediction_market_agent_tooling-0.48.15.dist-info/RECORD,,
87
+ prediction_market_agent_tooling-0.48.17.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
88
+ prediction_market_agent_tooling-0.48.17.dist-info/METADATA,sha256=sAyQzhlLTgPYGu4SF0z2dfSpSkZeJkZJYStbvagwh18,7848
89
+ prediction_market_agent_tooling-0.48.17.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
90
+ prediction_market_agent_tooling-0.48.17.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
91
+ prediction_market_agent_tooling-0.48.17.dist-info/RECORD,,