Skip to content

Commit f26f1ca

Browse files
fix logic in role tasks validation and teardown
1 parent 74422aa commit f26f1ca

File tree

1 file changed

+3
-5
lines changed
  • src/browsergym/workarena/tasks

1 file changed

+3
-5
lines changed

src/browsergym/workarena/tasks/role.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,17 @@ def validate(self, page: playwright.sync_api.Page, chat_messages: List[str]) ->
7979
)
8080
response.raise_for_status()
8181
result = response.json().get("result", [])
82-
roles = [elem["role"]["display_value"] for elem in result]
82+
role_to_sys_id_mapping = {elem["role"]["display_value"]: elem["sys_id"] for elem in result}
8383
for role in user_roles:
84-
if not role in roles:
84+
if not role in role_to_sys_id_mapping:
8585
return (
8686
0,
8787
False,
8888
"",
8989
{"message": "The role does not match."},
9090
)
9191
else:
92-
# find which row from result is associated with that role, get sys_id, and save
93-
sys_id = next((elem["sys_id"] for elem in result if elem["role"]["display_value"] == role), None)
94-
self.created_sysids.append(sys_id)
92+
self.created_sysids.append(role_to_sys_id_mapping[role])
9593
return (
9694
1,
9795
True,

0 commit comments

Comments
 (0)