Skip to content

Commit

Permalink
Reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
haiwei-luo committed Jul 24, 2024
1 parent 44239a3 commit 40cf4a0
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tasks/receptionist/src/receptionist/states/get_name_and_drink.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def execute(self, userdata: UserData) -> str:

return outcome


class PostRecoveryDecision(smach.State):
def __init__(
self,
Expand All @@ -96,7 +95,6 @@ def __init__(
self._possible_names = [name.lower() for name in prior_data["names"]]
self._possible_drinks = [drink.lower() for drink in prior_data["drinks"]]


def execute(self, userdata: UserData) -> str:
if not self._recovery_name_and_drink_required(userdata):
if userdata.guest_data[self._guest_id]["name"] == "unknown":
Expand All @@ -107,7 +105,6 @@ def execute(self, userdata: UserData) -> str:
outcome = "failed"
return outcome


def _recovery_name_and_drink_required(self, userdata: UserData) -> bool:
"""Determine whether both the name and drink requires recovery.
Expand Down Expand Up @@ -167,11 +164,11 @@ def __init__(
)

def __init__(
self,
guest_id: str,
last_resort: bool,
param_key: str = "/receptionist/priors",
):
self,
guest_id: str,
last_resort: bool,
param_key: str = "/receptionist/priors",
):

self._guest_id = guest_id
self._param_key = param_key
Expand All @@ -182,26 +179,32 @@ def __init__(
outcomes=["succeeded", "failed", "failed_name", "failed_drink"],
input_keys=["guest_transcription", "guest_data"],
output_keys=["guest_data", "guest_transcription"],

)
with self:

smach.StateMachine.add(
"PARSE_NAME_AND_DRINK",
self.ParseNameAndDrink(guest_id=self._guest_id, param_key=self._param_key),
self.ParseNameAndDrink(
guest_id=self._guest_id, param_key=self._param_key
),
transitions={"succeeded": "succeeded", "failed": "SPEECH_RECOVERY"},
)
smach.StateMachine.add(
"SPEECH_RECOVERY",
SpeechRecovery(self._guest_id, self._last_resort),
transitions={"succeeded": "succeeded", "failed": "POST_RECOVERY_DECISION"},
transitions={
"succeeded": "succeeded",
"failed": "POST_RECOVERY_DECISION",
},
)
smach.StateMachine.add(
"POST_RECOVERY_DECISION",
self.PostRecoveryDecision(guest_id=self._guest_id, param_key=self._param_key),
self.PostRecoveryDecision(
guest_id=self._guest_id, param_key=self._param_key
),
transitions={
"failed": "failed",
"failed_name": "failed_name",
"failed_drink": "failed_drink",
},
)
)

0 comments on commit 40cf4a0

Please sign in to comment.