Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
addressed code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
KahanMajmudar committed Nov 13, 2024
1 parent f50cc58 commit 752446a
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 60 deletions.
12 changes: 6 additions & 6 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
"contract/valory/mech_marketplace/0.1.0": "bafybeib7u3pt4xsviwa2kvpn4kxu3qmnygobhao6si5jqgdfutnlfwkjau",
"connection/valory/websocket_client/0.1.0": "bafybeic4ag3gqc7kd3k2o3pucddj2odck5yrfbgmwh5veqny7zao5qayli",
"skill/valory/contract_subscription/0.1.0": "bafybeiefuemlp75obgpxrp6iuleb3hn6vcviwh5oetk5djbuprf4xsmgjy",
"skill/valory/mech_abci/0.1.0": "bafybeigagkwqsps5l4bt2cinbd6qkxgrmciwc5iuqimakuq4ywkpkqqdhq",
"skill/valory/task_submission_abci/0.1.0": "bafybeidkelftx2o34iahldi4v4gsiogkkczw7rqdlszpazm23r3jaoneqq",
"skill/valory/task_execution/0.1.0": "bafybeif4lvkzqvnoxrahwufvb7hsh7zrhxchjvhggyjyndduyf6sit75vm",
"skill/valory/mech_abci/0.1.0": "bafybeig35ipz6x2ht6wmfb6ivxvyzf7yvtggvml63mqhpgy5o6zqj7rlo4",
"skill/valory/task_submission_abci/0.1.0": "bafybeihh7m4jvnn2sgr25kqfyn7qmrw6452kvrrsipuxruw272o5z6o6fm",
"skill/valory/task_execution/0.1.0": "bafybeiac2tl37wtrs6enevfphej3ltrrb3anibiip65rb6jbxae46uuose",
"skill/valory/websocket_client/0.1.0": "bafybeif7rrvsu6z4evqkhblxj3u6wwv2eqou576hgkyoehxuj7cntw7o2m",
"skill/valory/subscription_abci/0.1.0": "bafybeihs63kvsuiits4mumk47xzgftzisirwjslpo7dijbfmtd7wbajbri",
"agent/valory/mech/0.1.0": "bafybeify3mxiw7viii47pr6rvstp35n2vxq5pxiw7nboxrlq3ylbda562a",
"service/valory/mech/0.1.0": "bafybeidydigs4ilscddlaihrrlb6hqemjdxamkxsq4p4ycsxn3lu74uep4"
"skill/valory/subscription_abci/0.1.0": "bafybeie6iqkvupyyan4yqfnxu4z5ujfhzf36hkdwgktmcr7zabwo3zgj3i",
"agent/valory/mech/0.1.0": "bafybeifcyjrstnsr6aan7vndevisthxabk74a3tri7aibotvxkf3efipnu",
"service/valory/mech/0.1.0": "bafybeidjgkp3zmxnij3j3gnd67kacbeyzntxbkddh2cdonwryjhjx56z7u"
},
"third_party": {
"protocol/valory/default/1.0.0": "bafybeifqcqy5hfbnd7fjv4mqdjrtujh2vx3p2xhe33y67zoxa6ph7wdpaq",
Expand Down
16 changes: 8 additions & 8 deletions packages/valory/agents/mech/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ skills:
- valory/abstract_abci:0.1.0:bafybeieo7pe5wqjphs5izpz5aujjbubymlxub62b3rhx6yglu65ibalffu
- valory/abstract_round_abci:0.1.0:bafybeibiw4oqwqvo4jccwz5fb73iardzychgvcl66tceiildohoju2ikti
- valory/contract_subscription:0.1.0:bafybeiefuemlp75obgpxrp6iuleb3hn6vcviwh5oetk5djbuprf4xsmgjy
- valory/mech_abci:0.1.0:bafybeigagkwqsps5l4bt2cinbd6qkxgrmciwc5iuqimakuq4ywkpkqqdhq
- valory/mech_abci:0.1.0:bafybeig35ipz6x2ht6wmfb6ivxvyzf7yvtggvml63mqhpgy5o6zqj7rlo4
- valory/registration_abci:0.1.0:bafybeib3n6vqkfbrcubcbliebjnuwyywdinxkbzt76n6gbn2kg7ace47dq
- valory/reset_pause_abci:0.1.0:bafybeihkj6lmaypspyxe5qqrjgnolyck62pyvqoylr24ab6ue4steqcw7e
- valory/subscription_abci:0.1.0:bafybeihs63kvsuiits4mumk47xzgftzisirwjslpo7dijbfmtd7wbajbri
- valory/task_execution:0.1.0:bafybeif4lvkzqvnoxrahwufvb7hsh7zrhxchjvhggyjyndduyf6sit75vm
- valory/task_submission_abci:0.1.0:bafybeidkelftx2o34iahldi4v4gsiogkkczw7rqdlszpazm23r3jaoneqq
- valory/subscription_abci:0.1.0:bafybeie6iqkvupyyan4yqfnxu4z5ujfhzf36hkdwgktmcr7zabwo3zgj3i
- valory/task_execution:0.1.0:bafybeiac2tl37wtrs6enevfphej3ltrrb3anibiip65rb6jbxae46uuose
- valory/task_submission_abci:0.1.0:bafybeihh7m4jvnn2sgr25kqfyn7qmrw6452kvrrsipuxruw272o5z6o6fm
- valory/termination_abci:0.1.0:bafybeifi2uodnrjsrivj53g3sjutocmyusbx6mlsb6oanqdyt2mfbyvusy
- valory/transaction_settlement_abci:0.1.0:bafybeigh2vkt74jrad5gtsczrgqcuhcqe7jkgjy7jdw56yamlzwwnaymjy
- valory/websocket_client:0.1.0:bafybeif7rrvsu6z4evqkhblxj3u6wwv2eqou576hgkyoehxuj7cntw7o2m
Expand Down Expand Up @@ -228,9 +228,9 @@ models:
agent_funding_amount: ${int:200000000000000000}
minimum_agent_balance: ${int:100000000000000000}
termination_from_block: ${int:0}
mech_to_subscription: ${dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":["0x0000000000000000000000000000000000000000",
"1"],"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":["0x0000000000000000000000000000000000000001",
"2"]}}
mech_to_subscription: ${dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":{"tokenAddress":"0x0000000000000000000000000000000000000000",
"tokenId":"1"},"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":{"tokenAddress":"0x0000000000000000000000000000000000000001",
"tokenId":"2"}}}
hash_checkpoint_address: ${str:0x694e62BDF7Ff510A4EE66662cf4866A961a31653}
setup:
all_participants: ${list:["0x10E867Ac2Fb0Aa156ca81eF440a5cdf373bE1AaC"]}
Expand All @@ -243,7 +243,7 @@ models:
params:
args:
task_deadline: ${float:240.0}
tools_to_file_hash: ${dict:{"openai-gpt-3.5-turbo-instruct":"bafybeicziwfw7nb7gaxso357hrvtdlv6f23grm2c2rlfngpz4vbvoz2bke",
tools_to_package_hash: ${dict:{"openai-gpt-3.5-turbo-instruct":"bafybeicziwfw7nb7gaxso357hrvtdlv6f23grm2c2rlfngpz4vbvoz2bke",
"openai-gpt-3.5-turbo":"bafybeicziwfw7nb7gaxso357hrvtdlv6f23grm2c2rlfngpz4vbvoz2bke",
"openai-gpt-4":"bafybeicziwfw7nb7gaxso357hrvtdlv6f23grm2c2rlfngpz4vbvoz2bke",
"stabilityai-stable-diffusion-v1-5":"bafybeibaalr745aqajcaijykactx2nmg3jviefvnvpuk5kkxlt2yeedc2q",
Expand Down
40 changes: 21 additions & 19 deletions packages/valory/services/mech/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeif7ia4jdlazy6745ke2k2x5yoqlwsgwr6sbztbgqtwvs3ndm2p7ba
fingerprint_ignore_patterns: []
agent: valory/mech:0.1.0:bafybeify3mxiw7viii47pr6rvstp35n2vxq5pxiw7nboxrlq3ylbda562a
agent: valory/mech:0.1.0:bafybeifcyjrstnsr6aan7vndevisthxabk74a3tri7aibotvxkf3efipnu
number_of_agents: 4
deployment:
agent:
Expand Down Expand Up @@ -62,9 +62,9 @@ type: skill
metadata_hash: ${METADATA_HASH:str:f01701220caa53607238e340da63b296acab232c18a48e954f0af6ff2b835b2d93f1962f0}
profit_split_freq: ${PROFIT_SPLIT_FREQ:int:100}
hash_checkpoint_address: ${CHECKPOINT_ADDRESS:str:0x0000000000000000000000000000000000000000}
mech_to_subscription: ${MECH_TO_SUBSCRIPTION:${dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":["0x0000000000000000000000000000000000000000",
"1"],"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":["0x0000000000000000000000000000000000000001",
"2"]}}
mech_to_subscription: ${MECH_TO_SUBSCRIPTION:dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":{"tokenAddress":"0x0000000000000000000000000000000000000000",
"tokenId":"1"},"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":{"tokenAddress":"0x0000000000000000000000000000000000000001",
"tokenId":"2"}}}
agent_funding_amount: ${AGENT_FUNDING_AMOUNT:int:200000000000000000}
minimum_agent_balance: ${MINIMUM_AGENT_BALANCE:int:100000000000000000}
1:
Expand Down Expand Up @@ -99,9 +99,9 @@ type: skill
profit_split_freq: ${PROFIT_SPLIT_FREQ:int:100}
hash_checkpoint_address: ${CHECKPOINT_ADDRESS:str:0x0000000000000000000000000000000000000000}
service_endpoint_base: ${SERVICE_ENDPOINT_BASE:str:https://dummy_service.autonolas.tech/}
mech_to_subscription: ${MECH_TO_SUBSCRIPTION:${dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":["0x0000000000000000000000000000000000000000",
"1"],"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":["0x0000000000000000000000000000000000000001",
"2"]}}
mech_to_subscription: ${MECH_TO_SUBSCRIPTION:dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":{"tokenAddress":"0x0000000000000000000000000000000000000000",
"tokenId":"1"},"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":{"tokenAddress":"0x0000000000000000000000000000000000000001",
"tokenId":"2"}}}
agent_funding_amount: ${AGENT_FUNDING_AMOUNT:int:200000000000000000}
mech_marketplace_address: ${MECH_MARKETPLACE_ADDRESS:str:0x0000000000000000000000000000000000000000}
minimum_agent_balance: ${MINIMUM_AGENT_BALANCE:int:100000000000000000}
Expand Down Expand Up @@ -138,9 +138,9 @@ type: skill
metadata_hash: ${METADATA_HASH:str:f01701220caa53607238e340da63b296acab232c18a48e954f0af6ff2b835b2d93f1962f0}
profit_split_freq: ${PROFIT_SPLIT_FREQ:int:100}
hash_checkpoint_address: ${CHECKPOINT_ADDRESS:str:0x0000000000000000000000000000000000000000}
mech_to_subscription: ${MECH_TO_SUBSCRIPTION:${dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":["0x0000000000000000000000000000000000000000",
"1"],"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":["0x0000000000000000000000000000000000000001",
"2"]}}
mech_to_subscription: ${MECH_TO_SUBSCRIPTION:dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":{"tokenAddress":"0x0000000000000000000000000000000000000000",
"tokenId":"1"},"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":{"tokenAddress":"0x0000000000000000000000000000000000000001",
"tokenId":"2"}}}
agent_funding_amount: ${AGENT_FUNDING_AMOUNT:int:200000000000000000}
minimum_agent_balance: ${MINIMUM_AGENT_BALANCE:int:100000000000000000}
3:
Expand Down Expand Up @@ -176,7 +176,9 @@ type: skill
profit_split_freq: ${PROFIT_SPLIT_FREQ:int:100}
hash_checkpoint_address: ${CHECKPOINT_ADDRESS:str:0x0000000000000000000000000000000000000000}
service_endpoint_base: ${SERVICE_ENDPOINT_BASE:str:https://dummy_service.autonolas.tech/}
mech_to_subscription: ${MECH_TO_SUBSCRIPTION:list:[["0x77af31De935740567Cf4fF1986D04B2c964A786a",["0x0000000000000000000000000000000000000000","1"]]]}
mech_to_subscription: ${MECH_TO_SUBSCRIPTION:dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":{"tokenAddress":"0x0000000000000000000000000000000000000000",
"tokenId":"1"},"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":{"tokenAddress":"0x0000000000000000000000000000000000000001",
"tokenId":"2"}}}
agent_funding_amount: ${AGENT_FUNDING_AMOUNT:int:200000000000000000}
minimum_agent_balance: ${MINIMUM_AGENT_BALANCE:int:100000000000000000}
---
Expand All @@ -187,8 +189,8 @@ type: skill
params:
args:
task_deadline: ${TASK_DEADLINE:float:240.0}
tools_to_file_hash:
$TOOLS_TO_FILE_HASH:dict: {}
tools_to_package_hash:
$TOOLS_TO_PACKAGE_HASH:dict: {}
api_keys: ${API_KEYS:dict:{}}
polling_interval: ${POLLING_INTERVAL:float:30.0}
agent_index: ${AGENT_INDEX_0:int:0}
Expand All @@ -203,8 +205,8 @@ type: skill
params:
args:
task_deadline: ${TASK_DEADLINE:float:240.0}
tools_to_file_hash:
$TOOLS_TO_FILE_HASH:dict: {}
tools_to_package_hash:
$TOOLS_TO_PACKAGE_HASH:dict: {}
api_keys: ${API_KEYS:dict:{}}
polling_interval: ${POLLING_INTERVAL:float:30.0}
mech_marketplace_address: ${MECH_MARKETPLACE_ADDRESS:str:0x0000000000000000000000000000000000000000}
Expand All @@ -219,8 +221,8 @@ type: skill
params:
args:
task_deadline: ${TASK_DEADLINE:float:240.0}
tools_to_file_hash:
$TOOLS_TO_FILE_HASH:dict: {}
tools_to_package_hash:
$TOOLS_TO_PACKAGE_HASH:dict: {}
api_keys: ${API_KEYS:dict:{}}
polling_interval: ${POLLING_INTERVAL:float:30.0}
mech_marketplace_address: ${MECH_MARKETPLACE_ADDRESS:str:0x0000000000000000000000000000000000000000}
Expand All @@ -235,8 +237,8 @@ type: skill
params:
args:
task_deadline: ${TASK_DEADLINE:float:240.0}
tools_to_file_hash:
$TOOLS_TO_FILE_HASH:dict: {}
tools_to_package_hash:
$TOOLS_TO_PACKAGE_HASH:dict: {}
api_keys: ${API_KEYS:dict:{}}
mech_marketplace_address: ${MECH_MARKETPLACE_ADDRESS:str:0x0000000000000000000000000000000000000000}
polling_interval: ${POLLING_INTERVAL:float:30.0}
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/skills/mech_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ skills:
- valory/abstract_round_abci:0.1.0:bafybeibiw4oqwqvo4jccwz5fb73iardzychgvcl66tceiildohoju2ikti
- valory/registration_abci:0.1.0:bafybeib3n6vqkfbrcubcbliebjnuwyywdinxkbzt76n6gbn2kg7ace47dq
- valory/reset_pause_abci:0.1.0:bafybeihkj6lmaypspyxe5qqrjgnolyck62pyvqoylr24ab6ue4steqcw7e
- valory/task_submission_abci:0.1.0:bafybeidkelftx2o34iahldi4v4gsiogkkczw7rqdlszpazm23r3jaoneqq
- valory/task_submission_abci:0.1.0:bafybeihh7m4jvnn2sgr25kqfyn7qmrw6452kvrrsipuxruw272o5z6o6fm
- valory/termination_abci:0.1.0:bafybeifi2uodnrjsrivj53g3sjutocmyusbx6mlsb6oanqdyt2mfbyvusy
- valory/transaction_settlement_abci:0.1.0:bafybeigh2vkt74jrad5gtsczrgqcuhcqe7jkgjy7jdw56yamlzwwnaymjy
- valory/subscription_abci:0.1.0:bafybeihs63kvsuiits4mumk47xzgftzisirwjslpo7dijbfmtd7wbajbri
- valory/subscription_abci:0.1.0:bafybeie6iqkvupyyan4yqfnxu4z5ujfhzf36hkdwgktmcr7zabwo3zgj3i
behaviours:
main:
args: {}
Expand Down Expand Up @@ -83,7 +83,7 @@ models:
cleanup_history_depth: 1
cleanup_history_depth_current: null
drand_public_key: 868f005eb8e6e4ca0a47c8a77ceaa5309a47978a7c71bc5cce96366b5d7a569937c529eeda66c7293784a9402801af31
tools_to_file_hash: {}
tools_to_package_hash: {}
finalize_timeout: 60.0
genesis_config:
genesis_time: '2022-09-26T00:00:00.000000000Z'
Expand Down
3 changes: 2 additions & 1 deletion packages/valory/skills/subscription_abci/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def get_subscription_update_txs(
"""Get the mech update hash tx."""
txs = []
for mech_address, subscription in self.params.mech_to_subscription.items():
subscription_address, token_id = subscription
subscription_address = subscription.get("tokenAddress")
token_id = subscription.get("tokenId")
should_update = yield from self._should_update_subscription(
mech_address, subscription_address, token_id
)
Expand Down
4 changes: 2 additions & 2 deletions packages/valory/skills/subscription_abci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Params(BaseParams):
def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Initialize the parameters object."""

self.mech_to_subscription: Dict[str, List[str]] = self._ensure_get(
"mech_to_subscription", kwargs, Dict[str, List[str]]
self.mech_to_subscription: Dict[str, Dict[str, str]] = self._ensure_get(
"mech_to_subscription", kwargs, Dict[str, Dict[str, str]]
)
self.manual_gas_limit = self._ensure_get("manual_gas_limit", kwargs, int)
self.multisend_address = self._ensure_get("multisend_address", kwargs, str)
Expand Down
10 changes: 5 additions & 5 deletions packages/valory/skills/subscription_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeih2y4s3vu6xleujurx5mihfmzaxubeubykopyftjgklbwtfn6m5yu
behaviours.py: bafybeieegpu4ofx3npoofnzqc6mm7ncz6hfv56i6ih52haf46l2gdzel4y
behaviours.py: bafybeiddq3b7vlxz5s4s7pcyfarc7grxgjhfq7hmdm53kd63bxfeaanye4
dialogues.py: bafybeif2euu7wehnyr2r6efrbk6jh757dvbbnb3m7v5gxfdc4qzr3fnd74
fsm_specification.yaml: bafybeia77avtbeclmr4lil2hvjrxk4unstxb4fyvdmbpdgocn3ebs2hcdi
handlers.py: bafybeiegulbnno4efmaqmsuvjo4vrhcwcrg3faeryjjhwyabpywzty5m2u
models.py: bafybeicdcm3afzmszqk4gzjvjigi6v2olkzirjtvoereiixrhwssrqbjxq
models.py: bafybeihkg3otqrwjdq7inwcit7o736r4s7xm55yeculilpy6zhgba2jebu
payloads.py: bafybeidqcjuyceawnzf2dkeoro2geivfeqrh34h6a7lkxvfqcl62d4hyuy
rounds.py: bafybeigyyo3ztnqoolbrbz3cjq6vssedua7qawbemrp3mc6owqrpmew5wu
fingerprint_ignore_patterns: []
Expand Down Expand Up @@ -140,9 +140,9 @@ models:
slash_threshold_amount: 10000000000000000
light_slash_unit_amount: 5000000000000000
serious_slash_unit_amount: 8000000000000000
mech_to_subscription: ${dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":["0x0000000000000000000000000000000000000000",
"1"],"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":["0x0000000000000000000000000000000000000001",
"2"]}}
mech_to_subscription: ${dict:{"0x77af31De935740567Cf4fF1986D04B2c964A786a":{"tokenAddress":"0x0000000000000000000000000000000000000000",
"tokenId":"1"},"0xA6bE7Ef2e2FbdA7fB2BfE60726b74A3B2206D67f":{"tokenAddress":"0x0000000000000000000000000000000000000001",
"tokenId":"2"}}}
service_endpoint_base: https://dummy_service.autonolas.tech/
class_name: Params
requests:
Expand Down
10 changes: 5 additions & 5 deletions packages/valory/skills/task_execution/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self, **kwargs: Any):
# we only want to execute one task at a time, for the time being
self._executor = ProcessPoolExecutor(max_workers=1)
self._executing_task: Optional[Dict[str, Any]] = None
self._tools_to_file_hash: Dict[str, str] = {}
self._tools_to_package_hash: Dict[str, str] = {}
self._all_tools: Dict[str, Tuple[str, str, Dict[str, Any]]] = {}
self._inflight_tool_req: Optional[str] = None
self._done_task: Optional[Dict[str, Any]] = None
Expand All @@ -92,7 +92,7 @@ def __init__(self, **kwargs: Any):
def setup(self) -> None:
"""Implement the setup."""
self.context.logger.info("Setting up TaskExecutionBehaviour")
self._tools_to_file_hash = self.params.tools_to_file_hash
self._tools_to_package_hash = self.params.tools_to_package_hash
self._keychain = KeyChain(self.params.api_keys)

def act(self) -> None:
Expand Down Expand Up @@ -175,10 +175,10 @@ def _download_tools(self) -> None:
if self._inflight_tool_req is not None:
# there already is a req in flight
return
if len(self._tools_to_file_hash) == len(self._all_tools):
if len(self._tools_to_package_hash) == len(self._all_tools):
# we already have all the tools
return
for tool, file_hash in self._tools_to_file_hash.items():
for tool, file_hash in self._tools_to_package_hash.items():
if tool in self._all_tools:
continue
# read one at a time
Expand Down Expand Up @@ -422,7 +422,7 @@ def _handle_get_task(self, message: IpfsMessage, dialogue: Dialogue) -> None:
and "prompt" in task_data
and "tool" in task_data
) # pylint: disable=C0301
if is_data_valid and task_data["tool"] in self._tools_to_file_hash:
if is_data_valid and task_data["tool"] in self._tools_to_package_hash:
self._prepare_task(task_data)
elif is_data_valid:
tool = task_data["tool"]
Expand Down
16 changes: 10 additions & 6 deletions packages/valory/skills/task_execution/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class MechConfig:
is_marketplace_mech: bool

@staticmethod
def from_dict(raw_dict: Dict[str, Any]) -> "MechConfig":
def from_dict(raw_dict: Dict[bool, bool]) -> "MechConfig":
"""From dict."""
return MechConfig(
use_dynamic_pricing=raw_dict["use_dynamic_pricing"].lower() == "true",
is_marketplace_mech=raw_dict["is_marketplace_mech"].lower() == "true",
use_dynamic_pricing=raw_dict.get("use_dynamic_pricing"),
is_marketplace_mech=raw_dict.get("is_marketplace_mech"),
)


Expand All @@ -57,8 +57,8 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.api_keys: Dict[str, str] = self._ensure_get(
"api_keys", kwargs, Dict[str, str]
)
self.tools_to_file_hash: Dict[str, str] = self._ensure_get(
"tools_to_file_hash", kwargs, Dict[str, str]
self.tools_to_package_hash: Dict[str, str] = self._ensure_get(
"tools_to_package_hash", kwargs, Dict[str, str]
)
self.polling_interval = kwargs.get("polling_interval", 30.0)
self.task_deadline = kwargs.get("task_deadline", 240.0)
Expand All @@ -71,9 +71,13 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
self.max_block_window: int = self._ensure_get("max_block_window", kwargs, int)
# maps the request id to the number of times it has timed out
self.request_id_to_num_timeouts: Dict[int, int] = defaultdict(lambda: 0)
self.mech_to_config: Dict[str, Dict[str, bool]] = self._ensure_get(
mech_to_config_dict: Dict[str, Dict[str, bool]] = self._ensure_get(
"mech_to_config", kwargs, Dict[str, Dict[str, bool]]
)
self.mech_to_config: Dict[str, MechConfig] = {
key: MechConfig.from_dict(value)
for key, value in mech_to_config_dict.items()
}
self.agent_mech_contract_addresses = list(self.mech_to_config.keys())
self.mech_marketplace_address: str = self._ensure_get(
"mech_marketplace_address", kwargs, str
Expand Down
Loading

0 comments on commit 752446a

Please sign in to comment.