Skip to content

Commit

Permalink
Merge pull request #342 from valory-xyz/fix/tool-selection
Browse files Browse the repository at this point in the history
Fix tool selection
  • Loading branch information
Adamantios authored Oct 25, 2024
2 parents b213cb2 + 5a96784 commit b9f4d21
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
12 changes: 6 additions & 6 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
"contract/valory/staking_token/0.1.0": "bafybeigwsffbzx62d3ikz5kyjsewcvknrrnq3bcqgktnbrcpz4g6lyu3eq",
"contract/valory/relayer/0.1.0": "bafybeicawmds6czx7db2lcktvexwrp245jpekgulndtos5s5zdid3ilvq4",
"skill/valory/market_manager_abci/0.1.0": "bafybeicia7itulcrxlwbmhfzxppgo5i33tb2nmcycwizftw7gps4dareka",
"skill/valory/decision_maker_abci/0.1.0": "bafybeidcnpwi4o7z4wsenxz7tklagdchqunvmdqeyplcybwkoywmb7tvlu",
"skill/valory/trader_abci/0.1.0": "bafybeictsdzjcfvfc2exc5jn4xvkowr24flw65blrgb5uj4jzcdwr7kgpi",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeicdzirkebpbyhhkhordyte3gup32yt4nyfpijqihtpmceryrr5o74",
"skill/valory/decision_maker_abci/0.1.0": "bafybeiaiqddhwawt7u6stg6ujmzmnn3my7dtqa7tur5jbjfswnsasfoila",
"skill/valory/trader_abci/0.1.0": "bafybeidq5fxitj26rcy37pyrksoyks65zusndh6sor6ct5qv26kz3eupl4",
"skill/valory/tx_settlement_multiplexer_abci/0.1.0": "bafybeidw5cedygh25jtxdv35zb4223kbhtwv6enfxtkkdkuhuayvply5gq",
"skill/valory/staking_abci/0.1.0": "bafybeifyqszbiccxwwfldrl6lz5dspuaxbqd5qnniyecusddwvxpfwiyr4",
"skill/valory/check_stop_trading_abci/0.1.0": "bafybeicsrrxjs6bup267jiek3r7eutd42ssfyjthyvxfku6qozw3xebxta",
"agent/valory/trader/0.1.0": "bafybeihylp5xyzdngcfme3flt2kl6k66s7u4pvb7lsv27mbgotve4y57rq",
"service/valory/trader/0.1.0": "bafybeig2qzh3alfvlwlxuek6235ujplhvtysnfkeq4iu7y6x6lptt7376i",
"service/valory/trader_pearl/0.1.0": "bafybeig4um4w3d4hxz4luwiezdqveuvjm7jgn3axwysrik2xdw2b3rjpta"
"agent/valory/trader/0.1.0": "bafybeief2fkdv5pvryo6kyzguqhyfrvsxvb2sqnt4ptriairagjvuonttq",
"service/valory/trader/0.1.0": "bafybeig4b4v62lkebjacfstiizb3cr6ir6vtj6qhrfcpvry7vltikyqyyq",
"service/valory/trader_pearl/0.1.0": "bafybeicioq4b7o7ajmwigl66lvy2yiaprdagmrvz34awq55nxsoupr6ooe"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down
6 changes: 3 additions & 3 deletions packages/valory/agents/trader/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeigrdlxed3xlsnxtjhnsbl3cojruihxcqx4jxhgivkd5i2fkjncgba
- valory/termination_abci:0.1.0:bafybeib5l7jhew5ic6iq24dd23nidcoimzqkrk556gqywhoziatj33zvwm
- valory/transaction_settlement_abci:0.1.0:bafybeic7q7recyka272udwcupblwbkc3jkodgp74fvcdxb7urametg5dae
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeicdzirkebpbyhhkhordyte3gup32yt4nyfpijqihtpmceryrr5o74
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidw5cedygh25jtxdv35zb4223kbhtwv6enfxtkkdkuhuayvply5gq
- valory/market_manager_abci:0.1.0:bafybeicia7itulcrxlwbmhfzxppgo5i33tb2nmcycwizftw7gps4dareka
- valory/decision_maker_abci:0.1.0:bafybeidcnpwi4o7z4wsenxz7tklagdchqunvmdqeyplcybwkoywmb7tvlu
- valory/trader_abci:0.1.0:bafybeictsdzjcfvfc2exc5jn4xvkowr24flw65blrgb5uj4jzcdwr7kgpi
- valory/decision_maker_abci:0.1.0:bafybeiaiqddhwawt7u6stg6ujmzmnn3my7dtqa7tur5jbjfswnsasfoila
- valory/trader_abci:0.1.0:bafybeidq5fxitj26rcy37pyrksoyks65zusndh6sor6ct5qv26kz3eupl4
- valory/staking_abci:0.1.0:bafybeifyqszbiccxwwfldrl6lz5dspuaxbqd5qnniyecusddwvxpfwiyr4
- valory/check_stop_trading_abci:0.1.0:bafybeicsrrxjs6bup267jiek3r7eutd42ssfyjthyvxfku6qozw3xebxta
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader/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: bafybeigtuothskwyvrhfosps2bu6suauycolj67dpuxqvnicdrdu7yhtvq
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeihylp5xyzdngcfme3flt2kl6k66s7u4pvb7lsv27mbgotve4y57rq
agent: valory/trader:0.1.0:bafybeief2fkdv5pvryo6kyzguqhyfrvsxvb2sqnt4ptriairagjvuonttq
number_of_agents: 4
deployment:
agent:
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/services/trader_pearl/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibg7bdqpioh4lmvknw3ygnllfku32oca4eq5pqtvdrdsgw6buko7e
fingerprint_ignore_patterns: []
agent: valory/trader:0.1.0:bafybeihylp5xyzdngcfme3flt2kl6k66s7u4pvb7lsv27mbgotve4y57rq
agent: valory/trader:0.1.0:bafybeief2fkdv5pvryo6kyzguqhyfrvsxvb2sqnt4ptriairagjvuonttq
number_of_agents: 1
deployment:
agent:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def _fetch_accuracy_info(self) -> Generator[None, None, bool]:

return True

def _update_accuracy_store(self, local_tools: List[str]) -> None:
def _update_accuracy_store(self) -> None:
"""Update the accuracy store file with the latest information available"""
self.context.logger.info("Updating accuracy information of the policy...")
sep = self.acc_info_fields.sep
Expand All @@ -276,9 +276,17 @@ def _update_accuracy_store(self, local_tools: List[str]) -> None:
)
accuracy_store = self.policy.accuracy_store

# remove tools which are irrelevant
for tool in accuracy_store.copy():
if tool not in self.mech_tools:
accuracy_store.pop(tool, None)

# update the accuracy store using the latest accuracy information (only entered during the first period)
for row in reader:
tool = row[self.acc_info_fields.tool]
if tool not in accuracy_store.keys():
continue

# overwrite local with global information (naturally, no global information is available for pending)
accuracy_store[tool] = AccuracyInfo(
int(row[self.acc_info_fields.requests]),
Expand All @@ -288,7 +296,7 @@ def _update_accuracy_store(self, local_tools: List[str]) -> None:
)

# update the accuracy store by adding tools which we do not have any global information about yet
for tool in local_tools:
for tool in self.mech_tools:
accuracy_store.setdefault(tool, AccuracyInfo())

self.policy.update_weighted_accuracy()
Expand All @@ -298,21 +306,17 @@ def _set_policy(self) -> Generator:
if self.is_first_period or not self.synchronized_data.is_policy_set:
self.context.logger.debug("Setting initial policy")
self._policy = self._get_init_policy()
local_tools = self._try_recover_mech_tools()
if local_tools is None:
local_tools = self.mech_tools
else:
self.context.logger.debug(
"Reading policy information from synchronized data"
)
self._policy = self.synchronized_data.policy
local_tools = self.synchronized_data.available_mech_tools

if self.is_first_period:
yield from self.wait_for_condition_with_sleep(
self._fetch_accuracy_info, sleep_time_override=self.params.sleep_time
)
self._update_accuracy_store(local_tools)
self._update_accuracy_store()

def _try_recover_utilized_tools(self) -> Dict[str, str]:
"""Try to recover the utilized tools from the tools store."""
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/decision_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fingerprint:
behaviours/reedem.py: bafybeiaxwp4lx62owcaqfp6xcqh6567f5yvwnl4rage2f5hmq4nltkzjjy
behaviours/round_behaviour.py: bafybeih63hpia2bwwzu563hxs5yd3t5ycvxvkfnhvxbzghbyy3mw3xjl3i
behaviours/sampling.py: bafybeiekxzublnsvgjb2y2uvtye4zkethvmsxh4itonnwmb3sbviyyhsgq
behaviours/storage_manager.py: bafybeibnlg2eirzcxdpnuwbhzne77ear44cqwm4yae5bacgfu4vqqq7d7a
behaviours/storage_manager.py: bafybeif7mrnmhrarndx225e26jseuieosdja4jnlewnv2mtxqdydevxuze
behaviours/tool_selection.py: bafybeienlxcgjs3ogyofli3d7q3p5rst3mcxxcnwqf7qolqjeefjtixeke
dialogues.py: bafybeigpwuzku3we7axmxeamg7vn656maww6emuztau5pg3ebsoquyfdqm
fsm_specification.yaml: bafybeiabt2fonv63hozgr7bt4d5auom76iufzh6etpnmbwekktckz7644a
Expand Down
4 changes: 2 additions & 2 deletions packages/valory/skills/trader_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeic7q7recyka272udwcupblwbkc3jkodgp74fvcdxb7urametg5dae
- valory/termination_abci:0.1.0:bafybeib5l7jhew5ic6iq24dd23nidcoimzqkrk556gqywhoziatj33zvwm
- valory/market_manager_abci:0.1.0:bafybeicia7itulcrxlwbmhfzxppgo5i33tb2nmcycwizftw7gps4dareka
- valory/decision_maker_abci:0.1.0:bafybeidcnpwi4o7z4wsenxz7tklagdchqunvmdqeyplcybwkoywmb7tvlu
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeicdzirkebpbyhhkhordyte3gup32yt4nyfpijqihtpmceryrr5o74
- valory/decision_maker_abci:0.1.0:bafybeiaiqddhwawt7u6stg6ujmzmnn3my7dtqa7tur5jbjfswnsasfoila
- valory/tx_settlement_multiplexer_abci:0.1.0:bafybeidw5cedygh25jtxdv35zb4223kbhtwv6enfxtkkdkuhuayvply5gq
- valory/staking_abci:0.1.0:bafybeifyqszbiccxwwfldrl6lz5dspuaxbqd5qnniyecusddwvxpfwiyr4
- valory/check_stop_trading_abci:0.1.0:bafybeicsrrxjs6bup267jiek3r7eutd42ssfyjthyvxfku6qozw3xebxta
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protocols:
- valory/ledger_api:1.0.0:bafybeihdk6psr4guxmbcrc26jr2cbgzpd5aljkqvpwo64bvaz7tdti2oni
skills:
- valory/abstract_round_abci:0.1.0:bafybeib733xfbndtpvkf44mtk7oyodnficgloo6xhn7xmqxxeos33es65u
- valory/decision_maker_abci:0.1.0:bafybeidcnpwi4o7z4wsenxz7tklagdchqunvmdqeyplcybwkoywmb7tvlu
- valory/decision_maker_abci:0.1.0:bafybeiaiqddhwawt7u6stg6ujmzmnn3my7dtqa7tur5jbjfswnsasfoila
- valory/staking_abci:0.1.0:bafybeifyqszbiccxwwfldrl6lz5dspuaxbqd5qnniyecusddwvxpfwiyr4
- valory/mech_interact_abci:0.1.0:bafybeid6m3i5ofq7vuogqapdnoshhq7mswmudhvfcr2craw25fdwtoe3lm
behaviours:
Expand Down

0 comments on commit b9f4d21

Please sign in to comment.