Skip to content

Commit

Permalink
fix: linters
Browse files Browse the repository at this point in the history
  • Loading branch information
dvilelaf committed Jun 6, 2024
1 parent d12f13b commit 9867b70
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/dvilela/agents/tsunami/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/registration_abci:0.1.0:bafybeieu7vq3pyns4t5ty6u3sbmpkd7yznpg3rmqifoz3jhy7pmqyg3w6q
- valory/reset_pause_abci:0.1.0:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie
- dvilela/tsunami_abci:0.1.0:bafybeicd6ln65wjk2p6xexj5vs6w35f5qodn6rjj72ot7xt2oiyjra3dlu
- dvilela/tsunami_chained_abci:0.1.0:bafybeidgfufcnnzd3qoervzu3df7b3sxxcle72nnsttsrjk5o6ewots7hm
- dvilela/tsunami_abci:0.1.0:bafybeidh2oga4gda5ed6r4ww2qnxm63cr5kjhcmvmxxuftehp7yu2ioroe
- dvilela/tsunami_chained_abci:0.1.0:bafybeig6hwug4y54ofes52aaopzu6xwvovtcmj56nf5zqidhvdxhehckum
default_ledger: ethereum
required_ledgers:
- ethereum
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/services/tsunami/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: bafybeibh5bgshii5oqjfuhwmiivfvfqy7fw5pzvarxkpe4qrgivxtc3xym
fingerprint_ignore_patterns: []
agent: dvilela/tsunami:0.1.0:bafybeieraatvj2aisjpx4g4uzseiolm4qoqhw2izycjo5abzucnx3jja4y
agent: dvilela/tsunami:0.1.0:bafybeienvg3tkadcsqjqsklyv45cfiggypdkdlir2ah3xqu5ghpchcueay
number_of_agents: 1
deployment:
agent:
Expand Down
29 changes: 21 additions & 8 deletions packages/dvilela/skills/tsunami_abci/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,19 @@ def setup(self) -> None:

# Route regexes
hostname_regex = rf".*({config_uri_base_hostname}|{propel_uri_base_hostname}|localhost|127.0.0.1|0.0.0.0)(:\d+)?"
self.handler_url_regex = rf"{hostname_regex}\/.*"
self.handler_url_regex = ( # pylint: disable=attribute-defined-outside-init
rf"{hostname_regex}\/.*"
)
health_url_regex = rf"{hostname_regex}\/healthcheck"

# Routes
self.routes = {
self.routes = { # pylint: disable=attribute-defined-outside-init
(HttpMethod.GET.value, HttpMethod.HEAD.value): [
(health_url_regex, self._handle_get_health),
],
}

self.json_content_header = "Content-Type: application/json\n"
self.json_content_header = "Content-Type: application/json\n" # pylint: disable=attribute-defined-outside-init

@property
def synchronized_data(self) -> SynchronizedData:
Expand All @@ -162,6 +164,7 @@ def synchronized_data(self) -> SynchronizedData:

def _get_handler(self, url: str, method: str) -> Tuple[Optional[Callable], Dict]:
"""Check if an url is meant to be handled in this handler
We expect url to match the pattern {hostname}/.*,
where hostname is allowed to be localhost, 127.0.0.1 or the service_endpoint's hostname.
:param url: the url to check
Expand Down Expand Up @@ -195,6 +198,7 @@ def _get_handler(self, url: str, method: str) -> Tuple[Optional[Callable], Dict]
def handle(self, message: Message) -> None:
"""
Implement the reaction to an envelope.
:param message: the message
"""
http_msg = cast(HttpMessage, message)
Expand Down Expand Up @@ -241,6 +245,7 @@ def _handle_bad_request(
) -> None:
"""
Handle a Http bad request.
:param http_msg: the http message
:param http_dialogue: the http dialogue
"""
Expand All @@ -263,6 +268,7 @@ def _handle_get_health(
) -> None:
"""
Handle a Http request of verb GET.
:param http_msg: the http message
:param http_dialogue: the http dialogue
"""
Expand All @@ -274,14 +280,16 @@ def _handle_get_health(

round_sequence = cast(SharedState, self.context.state).round_sequence

if round_sequence._last_round_transition_timestamp:
if (
round_sequence._last_round_transition_timestamp # pylint: disable=protected-access
):
is_tm_unhealthy = cast(
SharedState, self.context.state
).round_sequence.block_stall_deadline_expired

current_time = datetime.now().timestamp()
seconds_since_last_transition = current_time - datetime.timestamp(
round_sequence._last_round_transition_timestamp
round_sequence._last_round_transition_timestamp # pylint: disable=protected-access
)

is_transitioning_fast = (
Expand All @@ -290,10 +298,15 @@ def _handle_get_health(
< 2 * self.context.params.reset_pause_duration
)

if round_sequence._abci_app:
current_round = round_sequence._abci_app.current_round.round_id
if round_sequence._abci_app: # pylint: disable=protected-access
current_round = (
round_sequence._abci_app.current_round.round_id # pylint: disable=protected-access
)
rounds = [
r.round_id for r in round_sequence._abci_app._previous_rounds[-25:]
r.round_id
for r in round_sequence._abci_app._previous_rounds[ # pylint: disable=protected-access
-25:
]
]
rounds.append(current_round)

Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/tsunami_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fingerprint:
behaviours.py: bafybeihq53pwa6njwjrpakp7qoeriw5kpzhjsacybtx2eoyxq4st2p5iqu
dialogues.py: bafybeidmgjji6zw6wcvhijrxb74batj2kc2lskfuqxv76duv2j7azcqwra
fsm_specification.yaml: bafybeibrbzzs726xnbay6yyknx7nkcyrvprrvb5sojlyxy4ndoksugcfq4
handlers.py: bafybeic6ezf3bdxpdkaqlytwsfbpixpoh6m45e2psjsfpnlq2mouf7xswu
handlers.py: bafybeihcbroggrgrz3pben7gnt336nl5fyjwhxabxhgtnzs7t3egxslnrm
models.py: bafybeiacefx5hniw3iaqcivvt4werwqebmbdk2mlm67ywglgesgdu2ewty
payloads.py: bafybeiapq3qfmrfusaoppkzce3mhzb4nryxz37wcgiivsjlvdzhdjhabba
prompts.py: bafybeifzfkcsiwaem45w2pji4gku3udx7kesflmgoz63xcwiby56nj6bbi
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/tsunami_chained_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeiameewywqigpupy3u2iwnkfczeiiucue74x2l5lbge74rmw6bgaie
- valory/transaction_settlement_abci:0.1.0:bafybeic3tccdjypuge2lewtlgprwkbb53lhgsgn7oiwzyrcrrptrbeyote
- valory/termination_abci:0.1.0:bafybeif2zim2de356eo3sipkmoev5emwadpqqzk3huwqarywh4tmqt3vzq
- dvilela/tsunami_abci:0.1.0:bafybeicd6ln65wjk2p6xexj5vs6w35f5qodn6rjj72ot7xt2oiyjra3dlu
- dvilela/tsunami_abci:0.1.0:bafybeidh2oga4gda5ed6r4ww2qnxm63cr5kjhcmvmxxuftehp7yu2ioroe
behaviours:
main:
args: {}
Expand Down
8 changes: 4 additions & 4 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"connection/dvilela/llama/0.1.0": "bafybeiauzzq2pxmn4brdqgdyxrrikbc5ywjpmetlajyohute5qtnn37aqq",
"connection/valory/twitter/0.1.0": "bafybeihotqawulig3g4a7fosi4pljsjii2neiqxtepd42e2neemhqecfcq",
"connection/dvilela/suno/0.1.0": "bafybeihy2phtjwbz27ntv55wxfk754kp5tjceujzsdbppjafljoydjflhi",
"skill/dvilela/tsunami_abci/0.1.0": "bafybeicd6ln65wjk2p6xexj5vs6w35f5qodn6rjj72ot7xt2oiyjra3dlu",
"skill/dvilela/tsunami_chained_abci/0.1.0": "bafybeidgfufcnnzd3qoervzu3df7b3sxxcle72nnsttsrjk5o6ewots7hm",
"agent/dvilela/tsunami/0.1.0": "bafybeieraatvj2aisjpx4g4uzseiolm4qoqhw2izycjo5abzucnx3jja4y",
"service/dvilela/tsunami/0.1.0": "bafybeiccrroao45eekfofhymxuwtwhyd6w5xnynizkvbtlydnozq3updam"
"skill/dvilela/tsunami_abci/0.1.0": "bafybeidh2oga4gda5ed6r4ww2qnxm63cr5kjhcmvmxxuftehp7yu2ioroe",
"skill/dvilela/tsunami_chained_abci/0.1.0": "bafybeig6hwug4y54ofes52aaopzu6xwvovtcmj56nf5zqidhvdxhehckum",
"agent/dvilela/tsunami/0.1.0": "bafybeienvg3tkadcsqjqsklyv45cfiggypdkdlir2ah3xqu5ghpchcueay",
"service/dvilela/tsunami/0.1.0": "bafybeibbk26g32u3lpdyyn5fqqinbrmdhg3xfs5breefwgj7zdkbm6ml7u"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down

0 comments on commit 9867b70

Please sign in to comment.