From 77c70a10957b3bfec3bf2b485cfc6a52af41c2b3 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 25 Oct 2023 12:44:16 +0300 Subject: [PATCH 1/2] fix: do not expect a strict response format Allow for extra keys so that updates on the mech do not result in breaking the trader if the utilized keys do not change. --- .../skills/decision_maker_abci/models.py | 33 ++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/packages/valory/skills/decision_maker_abci/models.py b/packages/valory/skills/decision_maker_abci/models.py index 76f7da667..ffc8f0d09 100644 --- a/packages/valory/skills/decision_maker_abci/models.py +++ b/packages/valory/skills/decision_maker_abci/models.py @@ -196,7 +196,7 @@ class MultisendBatch: operation: MultiSendOperation = MultiSendOperation.CALL -@dataclass +@dataclass(init=False) class PredictionResponse: """A response of a prediction.""" @@ -205,9 +205,14 @@ class PredictionResponse: confidence: float info_utility: float - def __post_init__(self) -> None: - """Runs checks on whether the current prediction response is valid or not.""" - # all the fields are probabilities + def __init__(self, **kwargs: Any) -> None: + """Initialize the mech's prediction ignoring extra keys.""" + self.p_yes = kwargs.pop("p_yes") + self.p_no = kwargs.pop("p_no") + self.confidence = kwargs.pop("confidence") + self.info_utility = kwargs.pop("info_utility") + + # all the fields are probabilities; run checks on whether the current prediction response is valid or not. probabilities = (getattr(self, field) for field in self.__annotations__) if ( any(not (0 <= prob <= 1) for prob in probabilities) @@ -223,18 +228,22 @@ def vote(self) -> Optional[int]: return None -@dataclass +@dataclass(init=False) class MechInteractionResponse: """A structure for the response of a mech interaction task.""" - requestId: int = 0 - result: Optional[PredictionResponse] = None - error: str = "Unknown" + request_id: int + result: Optional[PredictionResponse] + error: str + + def __init__(self, **kwargs: Any) -> None: + """Initialize the mech's response ignoring extra keys.""" + self.request_id = kwargs.pop("requestId", 0) + self.error = kwargs.pop("error", "Unknown") + result = kwargs.pop("result", None) - def __post_init__(self) -> None: - """Parses the nested part of the mech interaction response to a `PredictionResponse`.""" - if isinstance(self.result, str): - self.result = PredictionResponse(**json.loads(self.result)) + if isinstance(result, str): + self.result = PredictionResponse(**json.loads(result)) @classmethod def incorrect_format(cls, res: Any) -> "MechInteractionResponse": From 03145c258d54f3be32148b051b8a03bf30b96eca Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 25 Oct 2023 13:03:50 +0300 Subject: [PATCH 2/2] chore: run generators --- packages/packages.json | 10 +++++----- packages/valory/agents/trader/aea-config.yaml | 6 +++--- packages/valory/services/trader/service.yaml | 2 +- packages/valory/skills/decision_maker_abci/skill.yaml | 10 +++++----- packages/valory/skills/trader_abci/skill.yaml | 4 ++-- .../skills/tx_settlement_multiplexer_abci/skill.yaml | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index 17c7f9c3f..acb7f2c61 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,13 +1,13 @@ { "dev": { "skill/valory/market_manager_abci/0.1.0": "bafybeigmy3g2klkzdhttti2ouxf575ua5y7ajmh4a3yfpukeukqxjky47m", - "skill/valory/decision_maker_abci/0.1.0": "bafybeiac5tj4x22dgzaq62ja5tudeyt6f27nhs5e3fulej5ayojye5oyzq", - "skill/valory/trader_abci/0.1.0": "bafybeibspd55q2gm5un6wpfoq4zanho3nqwgzp42w63accgpyjo63cq6ie", + "skill/valory/decision_maker_abci/0.1.0": "bafybeib72et7lfim3s3swxj2yjg4sktdbbwhskij7hdxbbmbsr3pll4hou", + "skill/valory/trader_abci/0.1.0": "bafybeif472rqlrlfyl5orrgaj5t7qevbccv6xgl3olj53nrbc5vdpfpbcq", "contract/valory/market_maker/0.1.0": "bafybeif4mm2s3gxtvp227yypkcnna5ftec7vajcftvtbdmqddh7nprah5m", - "agent/valory/trader/0.1.0": "bafybeicfyo2qkrqep6o2dhp56eqt4zb6cqz33o753zh3wewgwx5rwn6p6m", - "service/valory/trader/0.1.0": "bafybeib46qrohyfex5g34wqtqt6ka2kzbkqllofw2knktve5hn3acf6isy", + "agent/valory/trader/0.1.0": "bafybeibwom2vpz2bkhdfclszqpaswhgafnkn5xyqi2jg6gs5tnvlrxorvq", + "service/valory/trader/0.1.0": "bafybeifljixfiawbcp7jo5ljjpxdxmmghy47ifhr2phu5uoxtzianhqje4", "contract/valory/erc20/0.1.0": "bafybeibysifjwhlcn7nntsjkowdmja53ed6urfzypi6sxfc7chtheecvpi", - "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiemvcwdd746zwhq3rtocpdcx3bj2crxmm2u5kebfsit3fkeq4oogm", + "skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeiddjn7jyhg2wjdtfex772vj7alopkszh6gejxqak332tdwvfuwavy", "contract/valory/mech/0.1.0": "bafybeifaavuqr2bz7nypapjwkufc5c6vwxm5ifucmtd3w7sh42tne35nga", "contract/valory/realitio/0.1.0": "bafybeic3wihpzz4deguslpzlnsgrlrabclq3njwuagyaiiv6rzqujfrs6e", "contract/valory/realitio_proxy/0.1.0": "bafybeidx37xzjjmapwacedgzhum6grfzhp5vhouz4zu3pvpgdy5pgb2fr4", diff --git a/packages/valory/agents/trader/aea-config.yaml b/packages/valory/agents/trader/aea-config.yaml index fd6b254ab..d9a956f61 100644 --- a/packages/valory/agents/trader/aea-config.yaml +++ b/packages/valory/agents/trader/aea-config.yaml @@ -41,10 +41,10 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeicpxn2khtaesuf4cq6ypwdmdmonlqroj2q2i6cxvpizc2y4cw66pe - valory/termination_abci:0.1.0:bafybeieqm46zuccaagnko3qlw6p3nvoohdrfgvpmw467r5lyil2dqrzjsy - valory/transaction_settlement_abci:0.1.0:bafybeia6cdxdlqrcwk2maw25fo7dafzd2p3rs7syropvufophk2pitzbwy -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiemvcwdd746zwhq3rtocpdcx3bj2crxmm2u5kebfsit3fkeq4oogm +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiddjn7jyhg2wjdtfex772vj7alopkszh6gejxqak332tdwvfuwavy - valory/market_manager_abci:0.1.0:bafybeigmy3g2klkzdhttti2ouxf575ua5y7ajmh4a3yfpukeukqxjky47m -- valory/decision_maker_abci:0.1.0:bafybeiac5tj4x22dgzaq62ja5tudeyt6f27nhs5e3fulej5ayojye5oyzq -- valory/trader_abci:0.1.0:bafybeibspd55q2gm5un6wpfoq4zanho3nqwgzp42w63accgpyjo63cq6ie +- valory/decision_maker_abci:0.1.0:bafybeib72et7lfim3s3swxj2yjg4sktdbbwhskij7hdxbbmbsr3pll4hou +- valory/trader_abci:0.1.0:bafybeif472rqlrlfyl5orrgaj5t7qevbccv6xgl3olj53nrbc5vdpfpbcq default_ledger: ethereum required_ledgers: - ethereum diff --git a/packages/valory/services/trader/service.yaml b/packages/valory/services/trader/service.yaml index dae7b8045..f711ec592 100644 --- a/packages/valory/services/trader/service.yaml +++ b/packages/valory/services/trader/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq fingerprint_ignore_patterns: [] -agent: valory/trader:0.1.0:bafybeicfyo2qkrqep6o2dhp56eqt4zb6cqz33o753zh3wewgwx5rwn6p6m +agent: valory/trader:0.1.0:bafybeibwom2vpz2bkhdfclszqpaswhgafnkn5xyqi2jg6gs5tnvlrxorvq number_of_agents: 4 deployment: {} --- diff --git a/packages/valory/skills/decision_maker_abci/skill.yaml b/packages/valory/skills/decision_maker_abci/skill.yaml index 68b7cff50..e36ec50c1 100644 --- a/packages/valory/skills/decision_maker_abci/skill.yaml +++ b/packages/valory/skills/decision_maker_abci/skill.yaml @@ -14,24 +14,24 @@ fingerprint: behaviours/__init__.py: bafybeih6ddz2ocvm6x6ytvlbcz6oi4snb5ee5xh5h65nq4w2qf7fd7zfky behaviours/base.py: bafybeidny4y4w4jbjbp5d5qivur6jm37fnuik4mqzchzshiuvpozxe7vwy behaviours/bet_placement.py: bafybeiauzdizqawjgzc3ugx33vuh726e25juhacqdr7c6uztpn6tra5dva - behaviours/blacklisting.py: bafybeie4aawdikv7pj5rorqy55jy2fkqzhitz3qmf3wyycarsj4dmwz7wa + behaviours/blacklisting.py: bafybeih2yrimf4l5t7mdqnmxv3zzv67fuzxytzbwcsmkcs5crbtmwccsry behaviours/decision_receive.py: bafybeibfnucc444uqcythgsn4cawluubbi4u4q7ab4aqc4ts3lu4qnvhdq behaviours/decision_request.py: bafybeibrk6jxalkgspinmjboqr3o6d6hl6mxtlkif74a5p32vp2zzhhzua behaviours/handle_failed_tx.py: bafybeidxpc6u575ymct5tdwutvzov6zqfdoio5irgldn3fw7q3lg36mmxm - behaviours/reedem.py: bafybeiccrnttqwf5vuf3lr55k5c6tsqsrekoypoag5gntyimjhbmuokkga + behaviours/reedem.py: bafybeihywv5332ngbz4hhcwjbaglctblwjbfhdenppznnlxbsgnxdhrrim behaviours/round_behaviour.py: bafybeig4tdktyu6hapoqymnxh2bgpds547st6a44heue657wkctwe4gjvm behaviours/sampling.py: bafybeiadikynvkaofbko72jc45xthhmmjfmlkpgramormhxwk5u47rnwdu behaviours/tool_selection.py: bafybeigfr2frkljrxyfxs5p3j42equzehgaqtkyuxk6eiujyudr6ajqakm dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm fsm_specification.yaml: bafybeifnob3ceim2mj7lqagtnpwqjqqxs5eg3oiwc73gwm6x5i2dvvlcya handlers.py: bafybeihj33szgrcxnpd73s4nvluyxwwsvhjum2cuq3ilhhe6vfola3k7vy - models.py: bafybeidlis33rkpvtb2w6qrtmiqzb4tbqfolkbbs6hk3jcx73lfuwqif3e + models.py: bafybeihp2heb2x7qyyvlaxr7slaxofflkhnrvrfdaorwc5ztnui2f7huly payloads.py: bafybeiawx6ix2ljvf545fe3wocdoh7frds6gjvzgv62b3w6huaolgvywqi - policy.py: bafybeidkqqrkgxah5q73mlpr64swxczadhuyax3ab2ijg6obemnvy2sxnu + policy.py: bafybeidpmx4ek3qze63zpuwixyf6t7bdv62ewgkzt3ljrzadiwdw64cueq redeem_info.py: bafybeibddfxwp3577c3dl2utaowwltquu5fg6crezpumoebw563wxpbfrm rounds.py: bafybeihopxmhzrpipc6r5x2vqf2tcixzuf5xdpqfsr7gr3n756n3ssft5q states/__init__.py: bafybeid23llnyp6j257dluxmrnztugo5llsrog7kua53hllyktz4dqhqoy - states/base.py: bafybeibx3kn2b3rovyiowjzpwhspjdbzyfroequg7zsjqsbdh5cyowu72a + states/base.py: bafybeihe72qgalihmtzaezy3bvodxiqiawv2gzlnrfnmegddf22brieyiu states/bet_placement.py: bafybeibalhxhp2c4oljmiwqi6ds3g36fgtabmf42mb5sgq6z22znrcbhda states/blacklisting.py: bafybeifruvxwwltndwazkzzbpc5nnnad3z5t5ofy6d3i7nssljbxl6gvxu states/decision_receive.py: bafybeifm3oyq2aji7f5yag6wpe4vr3ivi74pybdsk2jvmziiidx5nt7t4a diff --git a/packages/valory/skills/trader_abci/skill.yaml b/packages/valory/skills/trader_abci/skill.yaml index 2dacdc49c..654e1b4aa 100644 --- a/packages/valory/skills/trader_abci/skill.yaml +++ b/packages/valory/skills/trader_abci/skill.yaml @@ -25,8 +25,8 @@ skills: - valory/transaction_settlement_abci:0.1.0:bafybeia6cdxdlqrcwk2maw25fo7dafzd2p3rs7syropvufophk2pitzbwy - valory/termination_abci:0.1.0:bafybeieqm46zuccaagnko3qlw6p3nvoohdrfgvpmw467r5lyil2dqrzjsy - valory/market_manager_abci:0.1.0:bafybeigmy3g2klkzdhttti2ouxf575ua5y7ajmh4a3yfpukeukqxjky47m -- valory/decision_maker_abci:0.1.0:bafybeiac5tj4x22dgzaq62ja5tudeyt6f27nhs5e3fulej5ayojye5oyzq -- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiemvcwdd746zwhq3rtocpdcx3bj2crxmm2u5kebfsit3fkeq4oogm +- valory/decision_maker_abci:0.1.0:bafybeib72et7lfim3s3swxj2yjg4sktdbbwhskij7hdxbbmbsr3pll4hou +- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeiddjn7jyhg2wjdtfex772vj7alopkszh6gejxqak332tdwvfuwavy behaviours: main: args: {} diff --git a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml index 531820298..de9482f92 100644 --- a/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml +++ b/packages/valory/skills/tx_settlement_multiplexer_abci/skill.yaml @@ -20,7 +20,7 @@ contracts: [] protocols: [] skills: - valory/abstract_round_abci:0.1.0:bafybeid7neqpxxe4ualp23gxgrtpf6r5u3myr2mmc4uvwameyqshfdoydq -- valory/decision_maker_abci:0.1.0:bafybeiac5tj4x22dgzaq62ja5tudeyt6f27nhs5e3fulej5ayojye5oyzq +- valory/decision_maker_abci:0.1.0:bafybeib72et7lfim3s3swxj2yjg4sktdbbwhskij7hdxbbmbsr3pll4hou behaviours: main: args: {}