Skip to content

Commit 6e6a3ea

Browse files
changes to validators and data files for various tasks
1 parent eea7dea commit 6e6a3ea

File tree

11 files changed

+273
-79
lines changed

11 files changed

+273
-79
lines changed

src/browsergym/workarena/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from .tasks.incident import __TASKS__ as INCIDENT_TASKS
3636
from .tasks.license import __TASKS__ as LICENSE_TASKS
3737
from .tasks.ritm import __TASKS__ as RITM_TASKS
38+
from .tasks.user_group import __TASKS__ as USER_GROUP_TASKS
3839
from .tasks.compositional.base import CompositionalTask
3940

4041
ALL_WORKARENA_TASKS = [
@@ -68,6 +69,7 @@
6869
*LICENSE_TASKS,
6970
*RITM_TASKS,
7071
*FORM_WORKSPACE_TASKS,
72+
*USER_GROUP_TASKS,
7173
]
7274

7375

src/browsergym/workarena/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,12 @@
304304
DEACTIVATE_USER_GROUP_CONFIG_PATH = str(
305305
resources.files(data_files).joinpath("task_configs/deactivate_user_group.json")
306306
)
307+
CREATE_USER_GROUP_CONFIG_PATH = str(
308+
resources.files(data_files).joinpath("task_configs/create_user_group.json")
309+
)
310+
CREATE_USER_GROUP_ADD_USERS_CONFIG_PATH = str(
311+
resources.files(data_files).joinpath("task_configs/create_user_group_add_users.json")
312+
)
307313

308314
# service catalog tasks (dynamic guidance)
309315
ORDER_IPHONE_TASK_CONFIG_PATH = str(
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{
3+
"name": "ITIL User Group",
4+
"manager": "Pierre Salera",
5+
"type": "itil",
6+
"roles": "itil",
7+
"goal": "Create an active user group named \"ITIL User Group\". Its manager is Pierre Salera, type is itil, and roles include itil"
8+
},
9+
{
10+
"name": "Survey Admins",
11+
"manager": "Alene Rabeck",
12+
"type": "survey",
13+
"roles": "survey_admin",
14+
"goal": "Create an active user group named \"Survey Admins\". Its manager is Alene Rabeck, type is survey, and roles include survey_admin"
15+
},
16+
{
17+
"name": "Catalog Managers",
18+
"manager": "Zachary Mockus",
19+
"type": "catalog",
20+
"roles": "catalog_manager",
21+
"goal": "Create an active user group named \"Catalog Managers\". Its manager is Zachary Mockus, type is catalog, and roles include catalog_manager"
22+
}
23+
]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"name": "NYC Coed Soccer",
4+
"description": "We play at the Parade Grounds on Saturdays at 10",
5+
"members": "Chad Araiza, Eva Seahorn, Floyd Veazey",
6+
"goal": "Create an active user group with the name \"NYC Coed Soccer\" and description \"We play at the Parade Grounds on Saturdays at 10\". Add Chad Araiza, Eva Seahorn, Floyd Veazey to the group"
7+
},
8+
{
9+
"name": "NYC Run Club",
10+
"description": "We run Monday mornings at 7",
11+
"members": "Chad Araiza, Eva Seahorn, Floyd Veazey",
12+
"goal": "Create an active user group with the name \"NYC Run Club\" and description \"We run Monday mornings at 7\". Add Chad Araiza, Eva Seahorn, Floyd Veazey to the group"
13+
},
14+
{
15+
"name": "NYC Happy Hour Group",
16+
"description": "We get together for happy hour on Thursdays at 4",
17+
"members": "Chad Araiza, Eva Seahorn, Floyd Veazey",
18+
"goal": "Create an active user group with the name \"NYC Happy Hour Group\" and description \"We get together for happy hour on Thursdays at 4\". Add Chad Araiza, Eva Seahorn, Floyd Veazey to the group"
19+
}
20+
]

src/browsergym/workarena/data_files/task_configs/order_reset_password.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
[
22
{
33
"item": "SAP Payroll",
4-
"contact": "Email",
4+
"contact": "email",
55
"quantity": 1,
66
"goal": "Help me reset my password for SAP Payroll by submitting a request through the Service Catalog. Send the reset instructions to Email."
77
},
88
{
99
"item": "PeopleSoft CRM",
10-
"contact": "Telephone",
10+
"contact": "phone",
1111
"quantity": 1,
1212
"goal": "Help me reset my password for PeopleSoft CRM by submitting a request through the Service Catalog. Send the reset instructions to Telephone."
1313
},
1414
{
1515
"item": "Workday Enterprise Services",
16-
"contact": "SMS",
16+
"contact": "sms",
1717
"quantity": 1,
1818
"goal": "Help me reset my password for Workday Enterprise Services by submitting a request through the Service Catalog. Send the reset instructions to SMS."
1919
},
2020
{
2121
"item": "Slack",
22-
"contact": "Email",
22+
"contact": "email",
2323
"quantity": 1,
2424
"goal": "Help me reset my password for Slack by submitting a request through the Service Catalog. Send the reset instructions to Email."
2525
},
2626
{
2727
"item": "Windows Mobile",
28-
"contact": "SMS",
28+
"contact": "sms",
2929
"quantity": 1,
3030
"goal": "Help me reset my password for Windows Mobile by submitting a request through the Service Catalog. Send the reset instructions to SMS."
3131
}

src/browsergym/workarena/tasks/change_request.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ def teardown(self) -> None:
123123
# revert the change request approver state to the initial state
124124
if self.change_request_approver_sys_id is not None:
125125
try:
126-
table_api_call(
127-
instance=self.instance,
128-
table="sysapproval_approver",
129-
params={
130-
"sysparm_query": f"sys_id={self.change_request_approver_sys_id}",
131-
"sysparm_limit": 1,
126+
requests.patch(
127+
f"{self.instance.snow_url}/api/now/table/sysapproval_approver/{self.change_request_approver_sys_id}",
128+
auth=self.instance.snow_credentials,
129+
headers={"Accept": "application/json"},
130+
json={
131+
"state": self.initial_change_request_approver_state,
132132
},
133-
method="PUT",
134-
data={"state": self.initial_change_request_approver_state},
135133
)
136134
except HTTPError:
137135
pass

src/browsergym/workarena/tasks/incident.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,13 @@ def teardown(self):
113113
# revert the additional_assignee_list to the initial value
114114
if self.initial_incident_additional_assignee_list is not None and self.config["additional_assignee_list"] != self.initial_incident_additional_assignee_list:
115115
try:
116-
table_api_call(
117-
instance=self.instance,
118-
table="incident",
119-
params={
120-
"sysparm_query": f"number={self.config['incident_number']}",
121-
},
122-
data={
116+
requests.patch(
117+
f"{self.instance.snow_url}/api/now/table/incident/{self.config['incident_number']}",
118+
auth=self.instance.snow_credentials,
119+
headers={"Accept": "application/json"},
120+
json={
123121
"additional_assignee_list": self.initial_incident_additional_assignee_list,
124122
},
125-
method="PUT",
126123
)
127124
except HTTPError:
128125
pass
@@ -282,7 +279,7 @@ def _get_initial_incident_info(self):
282279
headers={"Accept": "application/json"},
283280
params={
284281
"sysparm_query": f"number={incident_number}",
285-
"sysparm_fields": "sys_id,number,close_code,close_notes",
282+
"sysparm_fields": "sys_id,number,close_code,close_notes,state",
286283
"sysparm_limit": 1,
287284
},
288285
)
@@ -292,6 +289,7 @@ def _get_initial_incident_info(self):
292289
raise ValueError(f"Incident {incident_number} not found")
293290

294291
self.incident_sys_id = result[0]["sys_id"]
292+
self.initial_incident_state = result[0]["state"]
295293
self.initial_incident_close_code = result[0]["close_code"]
296294

297295
def all_configs(self):
@@ -359,6 +357,7 @@ def teardown(self) -> None:
359357
json={
360358
"close_code": self.initial_incident_close_code,
361359
"close_notes": "",
360+
"state": self.initial_incident_state,
362361
},
363362
)
364363
except HTTPError:

src/browsergym/workarena/tasks/navigation.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,29 @@ def get_pretty_printed_description(self) -> str:
182182
def cheat(self, page: Page, chat_messages: list[str]) -> None:
183183
pass
184184

185+
def validate(
186+
self, page: playwright.sync_api.Page, chat_messages: list[str]
187+
) -> Tuple[float, bool, str, dict]:
188+
# we're less strict on the validation here.
189+
page.wait_for_load_state("domcontentloaded")
190+
191+
# Get the current URL and the final URL
192+
current_url = parse.urlunparse(
193+
parse.urlparse(parse.unquote(page.evaluate("() => window.location.href")))
194+
)
195+
final_url_tmp = self.module.get("url", "INVALID")
196+
final_url = parse.urlunparse(parse.urlparse(parse.unquote(final_url_tmp)))
197+
198+
if final_url in current_url:
199+
return (
200+
1,
201+
True,
202+
"Nice work, thank you!",
203+
{"message": "Correct module reached."},
204+
)
205+
206+
return 0, False, "", {"message": "Not at expected URL."}
207+
185208
class ImpersonationTask(AbstractServiceNowTask):
186209
"""
187210
Task to impersonate a user.

src/browsergym/workarena/tasks/ritm.py

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,18 @@ def teardown(self) -> None:
124124
# revert to previous state
125125
if self.initial_approval and self.initial_approval != self.config["approval"]:
126126
try:
127-
table_api_call(
128-
instance=self.instance,
129-
table="sc_req_item",
130-
params={
131-
"sysparm_query": f"number={self.config['ritm_number']}",
132-
"sysparm_fields": "sys_id,number,approval",
133-
"sysparm_limit": 1,
134-
},
135-
data={
127+
requests.patch(
128+
f"{self.instance.snow_url}/api/now/table/sc_req_item/{self.record_sys_id}",
129+
auth=self.instance.snow_credentials,
130+
headers={"Accept": "application/json"},
131+
json={
136132
"approval": self.initial_approval,
137133
},
138-
method="PUT",
139134
)
140135
except HTTPError:
141136
# sys_id was stored in local storage (for submitted)
142137
# but the record is absent from the database (probably invalid form)
143-
pass
144-
138+
pass
145139

146140
class UpdateRitmQuantityTask(ServiceNowRitmTask):
147141

@@ -215,24 +209,19 @@ def validate(self, page: playwright.sync_api.Page, chat_messages: List[str]) ->
215209
def teardown(self) -> None:
216210
if self.initial_quantity and self.initial_quantity != self.config["quantity"]:
217211
try:
218-
table_api_call(
219-
instance=self.instance,
220-
table="sc_req_item",
221-
params={
222-
"sysparm_query": f"number={self.config['ritm_number']}",
223-
"sysparm_fields": "sys_id,number,quantity",
224-
"sysparm_limit": 1,
225-
},
226-
data={
212+
requests.patch(
213+
f"{self.instance.snow_url}/api/now/table/sc_req_item/{self.record_sys_id}",
214+
auth=self.instance.snow_credentials,
215+
headers={"Accept": "application/json"},
216+
json={
227217
"quantity": self.initial_quantity,
228218
},
229-
method="PUT",
230219
)
231220
except HTTPError:
232221
# sys_id was stored in local storage (for submitted)
233222
# but the record is absent from the database (probably invalid form)
234223
pass
235-
224+
236225
__TASKS__ = [
237226
ChangeRitmStatusTask,
238227
UpdateRitmQuantityTask,

0 commit comments

Comments
 (0)