prediction-market-agent-tooling 0.57.19.dev351__py3-none-any.whl → 0.58.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.
- prediction_market_agent_tooling/config.py +32 -1
- prediction_market_agent_tooling/deploy/agent.py +2 -5
- prediction_market_agent_tooling/deploy/gcp/utils.py +0 -14
- {prediction_market_agent_tooling-0.57.19.dev351.dist-info → prediction_market_agent_tooling-0.58.0.dist-info}/METADATA +3 -1
- {prediction_market_agent_tooling-0.57.19.dev351.dist-info → prediction_market_agent_tooling-0.58.0.dist-info}/RECORD +8 -8
- {prediction_market_agent_tooling-0.57.19.dev351.dist-info → prediction_market_agent_tooling-0.58.0.dist-info}/WHEEL +1 -1
- {prediction_market_agent_tooling-0.57.19.dev351.dist-info → prediction_market_agent_tooling-0.58.0.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.57.19.dev351.dist-info → prediction_market_agent_tooling-0.58.0.dist-info}/entry_points.txt +0 -0
@@ -1,7 +1,9 @@
|
|
1
|
+
import json
|
1
2
|
import typing as t
|
3
|
+
from copy import deepcopy
|
2
4
|
|
3
5
|
from eth_account.signers.local import LocalAccount
|
4
|
-
from pydantic import Field
|
6
|
+
from pydantic import Field, model_validator
|
5
7
|
from pydantic.types import SecretStr
|
6
8
|
from pydantic.v1.types import SecretStr as SecretStrV1
|
7
9
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
@@ -9,6 +11,7 @@ from safe_eth.eth import EthereumClient
|
|
9
11
|
from safe_eth.safe.safe import SafeV141
|
10
12
|
from web3 import Account
|
11
13
|
|
14
|
+
from prediction_market_agent_tooling.deploy.gcp.utils import gcp_get_secret_value
|
12
15
|
from prediction_market_agent_tooling.gtypes import (
|
13
16
|
ChainID,
|
14
17
|
ChecksumAddress,
|
@@ -60,6 +63,34 @@ class APIKeys(BaseSettings):
|
|
60
63
|
ENABLE_CACHE: bool = False
|
61
64
|
CACHE_DIR: str = "./.cache"
|
62
65
|
|
66
|
+
@model_validator(mode="before")
|
67
|
+
@classmethod
|
68
|
+
def _model_validator(cls, data: t.Any) -> t.Any:
|
69
|
+
data = deepcopy(data)
|
70
|
+
data = cls._replace_gcp_secrets(data)
|
71
|
+
return data
|
72
|
+
|
73
|
+
@staticmethod
|
74
|
+
def _replace_gcp_secrets(data: t.Any) -> t.Any:
|
75
|
+
if isinstance(data, dict):
|
76
|
+
for k, v in data.items():
|
77
|
+
# Check if the value is meant to be fetched from GCP Secret Manager, if so, replace it with it.
|
78
|
+
if isinstance(v, (str, SecretStr)):
|
79
|
+
secret_value = (
|
80
|
+
v.get_secret_value() if isinstance(v, SecretStr) else v
|
81
|
+
)
|
82
|
+
if secret_value.startswith("gcps:"):
|
83
|
+
# We assume that secrets are dictionaries and the value is a key in the dictionary,
|
84
|
+
# example usage: `BET_FROM_PRIVATE_KEY=gcps:my-agent:private_key`
|
85
|
+
_, secret_name, key_name = secret_value.split(":")
|
86
|
+
secret_data = json.loads(gcp_get_secret_value(secret_name))[
|
87
|
+
key_name
|
88
|
+
]
|
89
|
+
data[k] = secret_data
|
90
|
+
else:
|
91
|
+
raise ValueError("Data must be a dictionary.")
|
92
|
+
return data
|
93
|
+
|
63
94
|
@property
|
64
95
|
def manifold_user_id(self) -> str:
|
65
96
|
return get_authenticated_user(
|
@@ -25,10 +25,7 @@ from prediction_market_agent_tooling.deploy.gcp.deploy import (
|
|
25
25
|
run_deployed_gcp_function,
|
26
26
|
schedule_deployed_gcp_function,
|
27
27
|
)
|
28
|
-
from prediction_market_agent_tooling.deploy.gcp.utils import
|
29
|
-
gcp_function_is_active,
|
30
|
-
gcp_resolve_api_keys_secrets,
|
31
|
-
)
|
28
|
+
from prediction_market_agent_tooling.deploy.gcp.utils import gcp_function_is_active
|
32
29
|
from prediction_market_agent_tooling.deploy.trade_interval import (
|
33
30
|
FixedInterval,
|
34
31
|
TradeInterval,
|
@@ -228,7 +225,7 @@ def {entrypoint_function_name}(request) -> str:
|
|
228
225
|
monitor_agent = MARKET_TYPE_TO_DEPLOYED_AGENT[market_type].from_api_keys(
|
229
226
|
name=gcp_fname,
|
230
227
|
start_time=start_time or utcnow(),
|
231
|
-
api_keys=
|
228
|
+
api_keys=api_keys,
|
232
229
|
)
|
233
230
|
env_vars |= monitor_agent.model_dump_prefixed()
|
234
231
|
|
@@ -8,7 +8,6 @@ from google.cloud.functions_v2.services.function_service.client import (
|
|
8
8
|
from google.cloud.functions_v2.types.functions import Function
|
9
9
|
from google.cloud.secretmanager import SecretManagerServiceClient
|
10
10
|
|
11
|
-
from prediction_market_agent_tooling.config import APIKeys
|
12
11
|
from prediction_market_agent_tooling.deploy.gcp.kubernetes_models import (
|
13
12
|
KubernetesCronJobsModel,
|
14
13
|
)
|
@@ -203,16 +202,3 @@ def gcp_get_secret_value(name: str, version: str = "latest") -> str:
|
|
203
202
|
return client.access_secret_version(
|
204
203
|
name=f"projects/{get_gcloud_project_id()}/secrets/{name}/versions/{version}"
|
205
204
|
).payload.data.decode("utf-8")
|
206
|
-
|
207
|
-
|
208
|
-
def gcp_resolve_api_keys_secrets(api_keys: APIKeys) -> APIKeys:
|
209
|
-
return APIKeys.model_validate(
|
210
|
-
api_keys.model_dump_public()
|
211
|
-
| {
|
212
|
-
k: gcp_get_secret_value(
|
213
|
-
name=v.rsplit(":", 1)[0],
|
214
|
-
version=v.rsplit(":", 1)[1],
|
215
|
-
)
|
216
|
-
for k, v in api_keys.model_dump_secrets().items()
|
217
|
-
}
|
218
|
-
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: prediction-market-agent-tooling
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.58.0
|
4
4
|
Summary: Tools to benchmark, deploy and monitor prediction market agents.
|
5
5
|
Author: Gnosis
|
6
6
|
Requires-Python: >=3.10,<3.13
|
@@ -38,6 +38,8 @@ Requires-Dist: openai (>=1.0.0,<2.0.0) ; extra == "openai"
|
|
38
38
|
Requires-Dist: optuna (>=4.1.0,<5.0.0) ; extra == "optuna"
|
39
39
|
Requires-Dist: pinatapy-vourhey (>=0.2.0,<0.3.0)
|
40
40
|
Requires-Dist: prompt-toolkit (>=3.0.43,<4.0.0)
|
41
|
+
Requires-Dist: proto-plus (>=1.0.0,<2.0.0)
|
42
|
+
Requires-Dist: protobuf (>=4.0.0,<5.0.0)
|
41
43
|
Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
|
42
44
|
Requires-Dist: pydantic (>=2.6.1,<3.0.0)
|
43
45
|
Requires-Dist: pydantic-settings (>=2.4.0,<3.0.0)
|
@@ -22,14 +22,14 @@ prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-
|
|
22
22
|
prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-CcAFJg1m9Y_XuaeIHPB29QR8,3971
|
23
23
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=MqTiaaJ3cYiOLUVR7OyImLWxcEya3Rl5JyFYW-K0lwM,17097
|
24
24
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=D0MfUkVZllmvcU0VOurk9tcKT7JTtwwOp-63zuCBVuc,2880
|
25
|
-
prediction_market_agent_tooling/config.py,sha256=
|
26
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
25
|
+
prediction_market_agent_tooling/config.py,sha256=owJ3goDbH1aeX8PzeJCeGK5pitYJqqk7yFOkaTbDarY,9209
|
26
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=3VzmTIekbICWrpoo0VjIbR7s_AKjhYaAaUP5RITDGek,23554
|
27
27
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
|
28
28
|
prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=kMrIE3wMv_IB6nJd_1DmDXDkEZhsXFOgyTd7JZ0gqHI,13068
|
29
29
|
prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
|
30
30
|
prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
|
31
31
|
prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=OsPboCFGiZKsvGyntGZHwdqPlLTthITkNF5rJFvGgU8,2582
|
32
|
-
prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=
|
32
|
+
prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=dzAvSQWRc2pndHFyKhVgrTtDm91K-csgusEaFRyfSow,5664
|
33
33
|
prediction_market_agent_tooling/deploy/trade_interval.py,sha256=Xk9j45alQ_vrasGvsNyuW70XHIQ7wfvjoxNR3F6HYCw,1155
|
34
34
|
prediction_market_agent_tooling/gtypes.py,sha256=G9KOKqYcxoKLv5Tfto4g5zq46FeIKxGl4RTArLIJn3I,2563
|
35
35
|
prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
@@ -117,8 +117,8 @@ prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=5iHO7-iehSlXuu
|
|
117
117
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
118
118
|
prediction_market_agent_tooling/tools/utils.py,sha256=jLG4nbEoIzzJiZ4RgMx4Q969Zdl0p0s63p8uET_0Fuw,6440
|
119
119
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=wqUDCed3iNrn1Wao1iwGN6tzIrhpzrTRj319wlveJEo,12275
|
120
|
-
prediction_market_agent_tooling-0.
|
121
|
-
prediction_market_agent_tooling-0.
|
122
|
-
prediction_market_agent_tooling-0.
|
123
|
-
prediction_market_agent_tooling-0.
|
124
|
-
prediction_market_agent_tooling-0.
|
120
|
+
prediction_market_agent_tooling-0.58.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
121
|
+
prediction_market_agent_tooling-0.58.0.dist-info/METADATA,sha256=E_PM7SHleOyz3e52aCzYfAdmKRrfRZqR05PzbQLZ6kk,8629
|
122
|
+
prediction_market_agent_tooling-0.58.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
123
|
+
prediction_market_agent_tooling-0.58.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
124
|
+
prediction_market_agent_tooling-0.58.0.dist-info/RECORD,,
|
File without changes
|