prediction-market-agent-tooling 0.22.0__py3-none-any.whl → 0.23.0__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.
@@ -1,13 +1,11 @@
1
+ import logging
1
2
  import sys
2
- import typing as t
3
+ import warnings
3
4
  from enum import Enum
4
5
 
5
6
  from loguru import logger
6
7
  from pydantic_settings import BaseSettings, SettingsConfigDict
7
8
 
8
- if t.TYPE_CHECKING:
9
- from loguru import Logger
10
-
11
9
 
12
10
  class LogFormat(str, Enum):
13
11
  DEFAULT = "default"
@@ -22,33 +20,56 @@ class LogConfig(BaseSettings):
22
20
  LOG_FORMAT: LogFormat = LogFormat.DEFAULT
23
21
 
24
22
 
25
- GCP_LOG_FORMAT = "{level:<.1}{time:MMDD HH:mm:ss.SSSSSS} {process} {name}:{line}] {message} | {extra}"
23
+ GCP_LOG_LOGURU_FORMAT = (
24
+ "{level:<.1}{time:MMDD HH:mm:ss} {process} {name}:{line}] {message}"
25
+ )
26
+ GCP_LOG_LOGGING_FORMAT, GCP_LOG_FORMAT_LOGGING_DATEFMT = (
27
+ "%(levelname).1s%(asctime)s %(process)d %(name)s:%(lineno)d] %(message)s"
28
+ ), "%m%d %H:%M:%S"
26
29
 
27
30
 
28
- def patch_logger(logger: "Logger") -> None:
31
+ def patch_logger() -> None:
29
32
  config = LogConfig()
30
33
 
31
34
  if config.LOG_FORMAT == LogFormat.GCP:
32
- format_ = GCP_LOG_FORMAT
35
+ format_loguru = GCP_LOG_LOGURU_FORMAT
36
+ format_logging = GCP_LOG_LOGGING_FORMAT
37
+ datefmt_logging = GCP_LOG_FORMAT_LOGGING_DATEFMT
33
38
 
34
39
  elif config.LOG_FORMAT == LogFormat.DEFAULT:
35
- format_ = None
40
+ format_loguru, format_logging, datefmt_logging = None, None, None
36
41
 
37
42
  else:
38
43
  raise ValueError(f"Unknown log format: {config.LOG_FORMAT}")
39
44
 
40
- if format_ is not None:
45
+ # Change built-in logging.
46
+ if format_logging is not None:
47
+ logging.basicConfig(
48
+ level=logging.DEBUG, format=format_logging, datefmt=datefmt_logging
49
+ )
50
+
51
+ # Change loguru.
52
+ if format_loguru is not None:
41
53
  logger.remove()
42
54
  logger.add(
43
55
  sys.stdout,
44
- format=format_,
56
+ format=format_loguru,
45
57
  level="DEBUG", # Can be the lowest level, higher ones will use by default this one.
46
58
  colorize=True,
47
59
  )
48
60
 
61
+ # Change warning formatting to a simpler one (no source code in a new line).
62
+ warnings.formatwarning = simple_warning_format
63
+ # Use logging module for warnings.
64
+ logging.captureWarnings(True)
65
+
49
66
  logger.info(f"Patched logger for {config.LOG_FORMAT.value} format.")
50
67
 
51
68
 
69
+ def simple_warning_format(message, category, filename, lineno, line=None): # type: ignore[no-untyped-def] # Not typed in the standard library neither.
70
+ return f"{category.__name__}: {message}"
71
+
72
+
52
73
  if not getattr(logger, "_patched", False):
53
- patch_logger(logger)
74
+ patch_logger()
54
75
  logger._patched = True # type: ignore[attr-defined] # Hacky way to store a flag on the logger object, to not patch it multiple times.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.22.0
3
+ Version: 0.23.0
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.12
@@ -19,7 +19,7 @@ prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5
19
19
  prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=qYIHRxQLac3yxtZ8ChikiPG9O1aUQucHW0muTSm1nto,2627
20
20
  prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=oyW0jgrUT2Tr49c7GlpcMsYNQjoCSOcWis3q-MmVAhU,6089
21
21
  prediction_market_agent_tooling/gtypes.py,sha256=xGSJXw12hzp8LwvQ956l01GiZMWd07MZTYqo8CXVeLY,2417
22
- prediction_market_agent_tooling/loggers.py,sha256=wIsV7DoB9XOWJKElSvP4ZeUqC0rArCMQS28wcZIYkww,1403
22
+ prediction_market_agent_tooling/loggers.py,sha256=0znHrzxSbeBaDiB920EZC6a2TiF0tw80Sa_yoLwvo_w,2289
23
23
  prediction_market_agent_tooling/markets/agent_market.py,sha256=qeuIXEujziDu_gQPvMiHsGSejhkPQtHhO_E7l16NOL0,5997
24
24
  prediction_market_agent_tooling/markets/categorize.py,sha256=yTd-lDMPW4ESDSzmxeLLBuzLX0FggOF7Vbswh7295o0,941
25
25
  prediction_market_agent_tooling/markets/data_models.py,sha256=uODY3aoFp8YYeLAUcrzMk1yU8pIKsTLobB9xIEGTmKs,1170
@@ -65,8 +65,8 @@ prediction_market_agent_tooling/tools/safe.py,sha256=h0xOO0eNtitClf0fPkn-0oTc6A_
65
65
  prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
66
66
  prediction_market_agent_tooling/tools/utils.py,sha256=zkmwPi3YisgZDPCeNwaRbL8sInOYOkvFgFY4Q8PbEo4,5077
67
67
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=cboATXNmEdn5RmPbVblHOwOdUMKBYrUK3GiI6i6Vzxo,9855
68
- prediction_market_agent_tooling-0.22.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
69
- prediction_market_agent_tooling-0.22.0.dist-info/METADATA,sha256=0hbWI60DDcdP3a4am9cGdGHx4J86DcH8gYmQ4oyAxfo,5563
70
- prediction_market_agent_tooling-0.22.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
71
- prediction_market_agent_tooling-0.22.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
72
- prediction_market_agent_tooling-0.22.0.dist-info/RECORD,,
68
+ prediction_market_agent_tooling-0.23.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
69
+ prediction_market_agent_tooling-0.23.0.dist-info/METADATA,sha256=gkLdQmTB2vbEO3toPUFru7h7BqsIvLm50aXGbNDK1xM,5563
70
+ prediction_market_agent_tooling-0.23.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
71
+ prediction_market_agent_tooling-0.23.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
72
+ prediction_market_agent_tooling-0.23.0.dist-info/RECORD,,