afp-sdk 0.6.0__py3-none-any.whl → 0.6.1__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.
- afp/schemas.py +12 -3
- afp/validators.py +15 -15
- {afp_sdk-0.6.0.dist-info → afp_sdk-0.6.1.dist-info}/METADATA +5 -3
- {afp_sdk-0.6.0.dist-info → afp_sdk-0.6.1.dist-info}/RECORD +6 -6
- {afp_sdk-0.6.0.dist-info → afp_sdk-0.6.1.dist-info}/WHEEL +0 -0
- {afp_sdk-0.6.0.dist-info → afp_sdk-0.6.1.dist-info}/licenses/LICENSE +0 -0
afp/schemas.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""AFP data structures."""
|
|
2
2
|
|
|
3
3
|
from decimal import Decimal
|
|
4
|
+
from itertools import chain
|
|
4
5
|
from typing import Annotated, Any, ClassVar, Literal, Self
|
|
5
6
|
|
|
6
7
|
from pydantic import AfterValidator, BeforeValidator, Field, model_validator
|
|
@@ -321,9 +322,17 @@ class PredictionProduct(Model):
|
|
|
321
322
|
self.product.min_price,
|
|
322
323
|
self.product.max_price,
|
|
323
324
|
)
|
|
324
|
-
validators.
|
|
325
|
-
|
|
326
|
-
|
|
325
|
+
validators.validate_outcome_space_template_variables(
|
|
326
|
+
[
|
|
327
|
+
self.outcome_space.base_case.condition,
|
|
328
|
+
self.outcome_space.base_case.fsp_resolution,
|
|
329
|
+
]
|
|
330
|
+
+ list(
|
|
331
|
+
chain.from_iterable(
|
|
332
|
+
[edge_case.condition, edge_case.fsp_resolution]
|
|
333
|
+
for edge_case in self.outcome_space.edge_cases
|
|
334
|
+
)
|
|
335
|
+
),
|
|
327
336
|
self.outcome_point.model_dump(),
|
|
328
337
|
)
|
|
329
338
|
if isinstance(self.outcome_space, OutcomeSpaceTimeSeries) and isinstance(
|
afp/validators.py
CHANGED
|
@@ -3,7 +3,7 @@ from datetime import date, datetime, timedelta
|
|
|
3
3
|
from decimal import Decimal
|
|
4
4
|
from functools import reduce
|
|
5
5
|
from operator import getitem
|
|
6
|
-
from typing import Any
|
|
6
|
+
from typing import Any, Iterable
|
|
7
7
|
|
|
8
8
|
import requests
|
|
9
9
|
from binascii import Error
|
|
@@ -178,23 +178,23 @@ def validate_oracle_fallback_fsp(
|
|
|
178
178
|
)
|
|
179
179
|
|
|
180
180
|
|
|
181
|
-
def
|
|
182
|
-
|
|
183
|
-
edge_case_conditions: list[str],
|
|
184
|
-
outcome_point_dict: dict[Any, Any],
|
|
181
|
+
def validate_outcome_space_template_variables(
|
|
182
|
+
values: Iterable[str], outcome_point_dict: dict[Any, Any]
|
|
185
183
|
) -> None:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
f"EdgeCase[{i}]" for i in range(len(edge_case_conditions))
|
|
189
|
-
]
|
|
190
|
-
for condition, schema in zip(conditions, schemas):
|
|
191
|
-
for variable in re.findall(r"{(.+?)}", condition):
|
|
192
|
-
parts = variable.split(".")
|
|
184
|
+
for value in values:
|
|
185
|
+
for variable in re.findall(r"{(.*?)}", value):
|
|
193
186
|
try:
|
|
194
|
-
reduce(
|
|
195
|
-
|
|
187
|
+
referred_value = reduce(
|
|
188
|
+
getitem, variable.split("."), outcome_point_dict
|
|
189
|
+
)
|
|
190
|
+
except (TypeError, KeyError):
|
|
191
|
+
raise ValueError(
|
|
192
|
+
f"OutcomeSpace: Invalid template variable '{variable}'"
|
|
193
|
+
)
|
|
194
|
+
if isinstance(referred_value, dict) or isinstance(referred_value, list): # type: ignore
|
|
196
195
|
raise ValueError(
|
|
197
|
-
f"
|
|
196
|
+
f"OutcomeSpace: Template variable '{variable}' "
|
|
197
|
+
"should not refer to a nested object or list"
|
|
198
198
|
)
|
|
199
199
|
|
|
200
200
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: afp-sdk
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Summary: Autonomous Futures Protocol Python SDK
|
|
5
5
|
Keywords: autonity,web3,trading,crypto,prediction,forecast,markets
|
|
6
6
|
License-Expression: MIT
|
|
@@ -256,8 +256,10 @@ tx = product.register(
|
|
|
256
256
|
)
|
|
257
257
|
```
|
|
258
258
|
|
|
259
|
-
See further code examples in the
|
|
259
|
+
See further code examples in the
|
|
260
|
+
[examples](https://github.com/autonity/afp-sdk/tree/master/examples/) directory.
|
|
260
261
|
|
|
261
262
|
## Development
|
|
262
263
|
|
|
263
|
-
See [DEVELOPMENT.md](
|
|
264
|
+
See [DEVELOPMENT.md](https://github.com/autonity/afp-sdk/blob/master/DEVELOPMENT.md)
|
|
265
|
+
for developer documentation.
|
|
@@ -41,10 +41,10 @@ afp/json-schemas/bafyreifcec2km7hxwq6oqzjlspni2mgipetjb7pqtaewh2efislzoctboi.jso
|
|
|
41
41
|
afp/json-schemas/bafyreihn3oiaxffe4e2w7pwtreadpw3obfd7gqlogbcxm56jc2hzfvco74.json,sha256=_tEqw3mqsdUP_sFwr8S1QZCbXxd3yJYjCHRuYnvoV2Y,4343
|
|
42
42
|
afp/json-schemas/bafyreihur3dzwhja6uxsbcw6eeoj3xmmc4e3zkmyzpot5v5dleevxe5zam.json,sha256=q-JNlC9Znh983Lp0qU8RYdj7VMtKCo4QRUS9OzchEeE,1427
|
|
43
43
|
afp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
|
-
afp/schemas.py,sha256=
|
|
44
|
+
afp/schemas.py,sha256=Qqjkx9IoKJPni_Tup_cgBPTTVfyfexyAjAe5CAU75RM,9456
|
|
45
45
|
afp/types.py,sha256=mI_PFMlVQvP9BJ50jzgvmUQPhTuP7TPP-JQOLvJr6mY,4691
|
|
46
|
-
afp/validators.py,sha256=
|
|
47
|
-
afp_sdk-0.6.
|
|
48
|
-
afp_sdk-0.6.
|
|
49
|
-
afp_sdk-0.6.
|
|
50
|
-
afp_sdk-0.6.
|
|
46
|
+
afp/validators.py,sha256=ogUzfJcqOsjosP0KncbxfbWVAOcjwEsE3LMmK4aeBFI,9256
|
|
47
|
+
afp_sdk-0.6.1.dist-info/licenses/LICENSE,sha256=ZdaKItgc2ppfqta2OJV0oHpSJiK87PUxmUkUo-_0SB8,1065
|
|
48
|
+
afp_sdk-0.6.1.dist-info/WHEEL,sha256=eh7sammvW2TypMMMGKgsM83HyA_3qQ5Lgg3ynoecH3M,79
|
|
49
|
+
afp_sdk-0.6.1.dist-info/METADATA,sha256=S286Fl-xYd50GYH4HnY_XdNXwi15IvXzICi15KvQKb0,8107
|
|
50
|
+
afp_sdk-0.6.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|